-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
58 lines (43 loc) · 1.36 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
FROM golang:1.22-alpine3.19 AS builder
RUN apk add build-base
WORKDIR /app
# copy the go.mod and go.sum and download the dependency first
# before copying the project
COPY go.mod /app
COPY go.sum /app
RUN go mod download
# NOW COPY the whole root project
COPY . /app
ARG ENVIRONMENT_NAME
ENV ENVIRONMENT_NAME=$ENVIRONMENT_NAME
RUN GOARCH=amd64 \
GOOS=linux \
CGO_ENABLED=0 \
go mod vendor
RUN go run ./cmd/seeder/main.go &&\
go build -o ./output/server ./cmd/server/main.go &&\
go build -o ./output/migrations ./cmd/migrations/main.go &&\
go build -o ./output/seeder ./cmd/seeder/exec/seed.go
FROM alpine:latest
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache --upgrade bash
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
ARG ENVIRONMENT_NAME
ENV ENVIRONMENT_NAME=$ENVIRONMENT_NAME
RUN mkdir -p /app/
WORKDIR /app
USER nonroot
COPY /scripts /app/scripts/
COPY --from=builder /app/output/ /app/
COPY --from=builder /app/cmd/seeder/exec/build/ /app/cmd/seeder/exec/build/
COPY ./.env.* /app/output/
COPY ./.env.* /app/output/cmd/seeder/exec/build/
COPY ./.env.* /app/output/cmd/seeder/exec/
COPY ./.env.* /app/output/cmd/seeder/
COPY ./.env.* /app/output/cmd/
COPY ./.env.* /app/
COPY ./scripts/ /app/
COPY --from=builder /app/internal/migrations/ /app/internal/migrations/
CMD ["bash","./migrate-and-run.sh"]
EXPOSE 9000