-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
61 lines (43 loc) · 1.69 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
# syntax=docker/dockerfile:1.3
####################################################################################################
# Stage: base-deps
FROM golang:1.21-bullseye as base-deps
ENV WORKSPACE_PATH=/workspace/migrations
WORKDIR /workspace/migrations
COPY src/migrations/go.mod src/migrations/go.sum ./src/migrations/
RUN cd src/migrations && go mod download
EXPOSE 5000
####################################################################################################
# Stage: dev-deps
FROM base-deps AS dev-deps
# Install dev dependencies
####################################################################################################
# Stage: dev-test
FROM dev-deps AS dev-test
ARG BUILD_TYPE
LABEL build-type=$BUILD_TYPE
LABEL git-hash=$GIT_HASH
LABEL git-tag=$GIT_TAG
COPY src/migrations/go.mod src/migrations/go.sum src/migrations/
COPY files files
COPY src/migrations/cmd src/migrations/cmd
COPY src/migrations/internal src/migrations/internal
RUN cd src/migrations \
&& CGO_ENABLED=0 GOOS=linux go build -a -o ${WORKSPACE_PATH}/migrate cmd/*.go
CMD ["bash", "-c", "${WORKSPACE_PATH}/migrate"]
####################################################################################################
# Stage: prod
FROM base-deps AS prod
ARG BUILD_TYPE
ARG GIT_HASH
ARG GIT_TAG
LABEL build-type=$BUILD_TYPE
LABEL git-hash=$GIT_HASH
LABEL git-tag=$GIT_TAG
COPY src/migrations/go.mod src/migrations/go.sum src/migrations/
COPY files files
COPY src/migrations/cmd src/migrations/cmd
COPY src/migrations/internal src/migrations/internal
RUN cd src/migrations \
&& CGO_ENABLED=0 GOOS=linux go build -a -o ${WORKSPACE_PATH}/migrate cmd/*.go
CMD ["bash", "-c", "${WORKSPACE_PATH}/migrate"]