63 lines
1.7 KiB
Docker
63 lines
1.7 KiB
Docker
FROM golang:1.22-alpine as base
|
|
|
|
ARG VERSION="unknown"
|
|
ARG REVISION="unknown"
|
|
ARG BUILDTIME=""
|
|
|
|
WORKDIR /go/src/git.loyso.art/frx/devsim
|
|
|
|
ENV GOCACHE=/go/pkg/mod/
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
--mount=type=bind,source=go.sum,target=go.sum \
|
|
--mount=type=bind,source=go.mod,target=go.mod \
|
|
go mod download -x && go mod verify
|
|
COPY . .
|
|
|
|
FROM base as build-utils
|
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
go build \
|
|
-o /go/bin/utils \
|
|
/go/src/git.loyso.art/frx/devsim/cmd/utility/main.go
|
|
|
|
FROM base as build-web
|
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
go build \
|
|
-ldflags "-w -s -X 'git.loyso.art/frx/devsim.Version=${VERSION}' -X 'git.loyso.art/frx/devsim.Revision=${REVISION}' -X 'git.loyso.art/frx/devsim.BuildTime=${BUILDTIME}'" \
|
|
-o /go/bin/web \
|
|
/go/src/git.loyso.art/frx/devsim/cmd/web/main.go
|
|
|
|
FROM base as build-migrator
|
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
go build -o /go/bin/migrator \
|
|
/go/src/git.loyso.art/frx/devsim/cmd/migrator/main.go
|
|
|
|
FROM gcr.io/distroless/static-debian12@sha256:ce46866b3a5170db3b49364900fb3168dc0833dfb46c26da5c77f22abb01d8c3 as web
|
|
|
|
WORKDIR /app
|
|
COPY --from=build-web /go/bin/web /app/web
|
|
COPY --from=build-utils /go/bin/utils /app/utils
|
|
|
|
ENV DEVSIM_HTTP_ADDR=":80"
|
|
EXPOSE 80
|
|
|
|
ENV DEVSIM_MONITOR_ADDR=":8080"
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s \
|
|
CMD ["/app/utils", "health"]
|
|
|
|
ENTRYPOINT ["/app/web"]
|
|
|
|
FROM gcr.io/distroless/static-debian12@sha256:ce46866b3a5170db3b49364900fb3168dc0833dfb46c26da5c77f22abb01d8c3 as migrator
|
|
|
|
WORKDIR /app
|
|
COPY --from=build-migrator /go/bin/migrator /app/migrator
|
|
|
|
COPY assets/db/migrations/ /app/db/migrations/
|
|
ENV DEVSIM_PG_MIGRATOR="/app/migrations"
|
|
|
|
ENTRYPOINT ["/app/migrator"]
|
|
|
|
|