forked from LondheShubham153/retail-store-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (41 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
57 lines (41 loc) · 1.22 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
57
# Build Stage
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 AS build-env
# We tell DNF not to install Recommends and Suggests packages, which are
# weak dependencies in DNF terminology, thus keeping our installed set of
# packages as minimal as possible.
RUN dnf --setopt=install_weak_deps=False install -q -y \
git \
golang \
&& \
dnf clean all
RUN mkdir -p "${GOPATH}/src" "${GOPATH}/bin" /appsrc
WORKDIR /appsrc
ENV GOPROXY=https://goproxy.io,direct
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o main main.go
# Final stage
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
ENV APPUSER=appuser
ENV APPUID=1000
ENV APPGID=1000
# We tell DNF not to install Recommends and Suggests packages, which are
# weak dependencies in DNF terminology, thus keeping our installed set of
# packages as minimal as possible.
RUN dnf --setopt=install_weak_deps=False install -q -y \
shadow-utils \
&& \
dnf clean all
RUN useradd \
--home "/app" \
--create-home \
--user-group \
--uid "$APPUID" \
"$APPUSER"
WORKDIR /app
USER appuser
COPY --chown=appuser:appuser --from=build-env /appsrc/main /app/
COPY ./ATTRIBUTION.md ./LICENSES.md
ENV GIN_MODE=release
ENTRYPOINT ["/app/main"]