-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
31 lines (23 loc) · 850 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
FROM golang:1.20-alpine as builder
RUN apk add --no-cache git
RUN apk add --update make
RUN apk add --no-cache openssh
# Move to working directory /app
WORKDIR /app
# Copy the code into the container
COPY . .
# Toggle CGO on your app requirement
RUN CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' -o /app/appbin ./cmd/main.go
FROM alpine:latest
LABEL MAINTAINER Author mohamed abdelmohaimen
# Add new user 'appuser'. App should be run without root privileges as a security measure
RUN adduser --home "/appuser" --disabled-password appuser \
--gecos "appuser,-,-,-"
USER appuser
COPY --from=builder /app/internal/server/http/web /home/appuser/app/web
COPY --from=builder /app/appbin /home/appuser/app
WORKDIR /home/appuser/app
# Export necessary port
EXPOSE 9090
# Command to run when starting the container
CMD ["./appbin"]