omnix-sopiga/Dockerfile

37 lines
1.1 KiB
Docker
Raw Permalink Normal View History

# Build context: PARENT directory of this repo, i.e. the folder that
# contains both `omnix-sopiga/` and `go-dw-framework/` as siblings:
#
# docker build -f omnix-sopiga/Dockerfile -t omnix-sopiga ..
#
# Why: go.mod still uses a local `replace` directive pointing at
# ../go-dw-framework (see go.mod) for pre-release development, since
# go-dw-framework isn't tagged/published yet. Once it is tagged (e.g. v0.1.0)
# and reachable from the Docker build environment:
# 1. go.mod: remove the `replace` line, keep `require ... v0.1.0`
# 2. This Dockerfile: build context becomes just this repo (`.`), and the
# COPY lines below collapse to `COPY . .`
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git
WORKDIR /src
COPY go-dw-framework ./go-dw-framework
COPY omnix-sopiga ./omnix-sopiga
WORKDIR /src/omnix-sopiga
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/omnix-sopiga .
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata && \
adduser -D -u 10001 app
USER app
WORKDIR /app
COPY --from=builder /out/omnix-sopiga .
COPY omnix-sopiga/migrations ./migrations
EXPOSE 8081
ENTRYPOINT ["./omnix-sopiga"]