-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
33 lines (22 loc) · 888 Bytes
/
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
# Builder Image
# ---------------------------------------------------
FROM dimaskiddo/alpine:go-1.19 AS go-builder
WORKDIR /usr/src/app
COPY . ./
RUN go mod download \
&& CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o main cmd/main/main.go
# Final Image
# ---------------------------------------------------
FROM dimaskiddo/alpine:base
MAINTAINER Dimas Restu Hidayanto <[email protected]>
ARG SERVICE_NAME="codebase-go-rest"
ENV PATH="$PATH:/usr/app/${SERVICE_NAME}" \
CONFIG_ENV="production"
WORKDIR /usr/app/${SERVICE_NAME}
COPY --from=go-builder /usr/src/app/config/ ./config
COPY --from=go-builder /usr/src/app/main ./main
RUN chmod 777 config/stores config/uploads
EXPOSE 3000
HEALTHCHECK --interval=5s --timeout=3s CMD ["curl", "http://127.0.0.1:3000/health"] || exit 1
VOLUME ["/usr/app/config/stores","/usr/app/config/uploads"]
CMD ["main"]