-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (41 loc) · 1.19 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (41 loc) · 1.19 KB
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
FROM golang:1.27-alpine3.24@sha256:8a5910f31396cd4d89662f56c68b3ae31d374308270a1c3bd96672ee5ed43414 AS builder
ARG DIR=/app
WORKDIR ${DIR}
ARG APP=nodemon
ARG TARGETOS
ARG TARGETARCH
RUN apk add --no-cache make git
# disable cgo for go build
ENV CGO_ENABLED=0
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy the .git directory and restore the worktree, also handle current possible changes in go.mod and go.sum
COPY .git .git
RUN git restore --source=HEAD --worktree .
COPY go.mod .
COPY go.sum .
# Copy the necessary files for building and override the restored worktree
COPY Makefile .
COPY cmd .
COPY pkg .
COPY internal internal
RUN make build-$APP-$TARGETOS-$TARGETARCH
FROM alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
ARG DIR=/app
ENV TZ=Etc/UTC \
APP_USER=appuser
ARG APP=nodemon
ARG TARGETOS
ARG TARGETARCH
STOPSIGNAL SIGINT
RUN addgroup -S $APP_USER \
&& adduser -S $APP_USER -G $APP_USER
RUN apk add --no-cache bind-tools
USER $APP_USER
WORKDIR ${DIR}
# Considered as a default HTTP API Port, NATS embedded server port
EXPOSE 8080
EXPOSE 4222
COPY --from=builder ${DIR}/build/$TARGETOS-$TARGETARCH/$APP ${DIR}/$APP
ENTRYPOINT ["./$APP"]