-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
69 lines (50 loc) · 1.83 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder
WORKDIR /work
ENV CGO_ENABLED 0
RUN apk add --update --no-cache git
COPY ./go.* ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
ARG APP_VERSION=dev
ARG APP_REVISION=local
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
FROM --platform=$BUILDPLATFORM builder AS builder-ns-migrate
ARG SQLDEF_VERSION=v0.16.12
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
go install -ldflags "-s -w -X main.version=$SQLDEF_VERSION" github.com/sqldef/sqldef/cmd/mysqldef@$SQLDEF_VERSION
# keep output directory the same between platforms; workaround for https://github.com/golang/go/issues/57485
RUN cp /go/bin/mysqldef /mysqldef || cp /go/bin/"$GOOS"_"$GOARCH"/mysqldef /mysqldef
FROM --platform=$BUILDPLATFORM builder AS builder-ns
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
go build -o /app/ns -ldflags "-s -w -X main.version=$APP_VERSION -X main.revision=$APP_REVISION" ./cmd
FROM alpine:3 AS base
WORKDIR /app
ARG APP_VERSION=dev
ARG APP_REVISION=local
ENV APP_VERSION=$APP_VERSION
ENV APP_REVISION=$APP_REVISION
FROM base AS ns-migrate
COPY ./migrations/entrypoint.sh ./
COPY ./migrations/schema.sql ./
COPY --from=builder-ns-migrate /mysqldef /usr/local/bin/
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/app/schema.sql"]
FROM base AS ns
COPY --from=builder-ns /app/ns ./
ENTRYPOINT ["/app/ns"]
FROM ns AS ns-auth-dev
ENTRYPOINT ["/app/ns", "auth-dev"]
FROM ns AS ns-builder
ENTRYPOINT ["/app/ns", "builder"]
FROM ns AS ns-controller
ENTRYPOINT ["/app/ns", "controller"]
FROM ns AS ns-gateway
ENTRYPOINT ["/app/ns", "gateway"]
FROM ns AS ns-gitea-integration
ENTRYPOINT ["/app/ns", "gitea-integration"]
FROM ns AS ns-ssgen
ENTRYPOINT ["/app/ns", "ssgen"]