-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.terraform
38 lines (29 loc) · 1022 Bytes
/
Dockerfile.terraform
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
ARG GO_VER=1.22
ARG ALPINE_VER=3.20
# first build stage
# by default uses alpine-based image
# golang 1.22
# alpine 3.20
# arch linux/amd64
FROM golang:${GO_VER}-alpine${ALPINE_VER} AS builder
# copy all source code for build
WORKDIR /src
# install updates and build executable
RUN apk upgrade --no-cache -X https://mirror.yandex.ru/mirrors/alpine/v3.20/main && \
apk add make
COPY . .
RUN make sgroups-tf-v2 platform=linux/amd64
# arch linux/amd64
FROM alpine:${ALPINE_VER}
# create user other than root and install updated
RUN addgroup -g 101 app && \
adduser -H -u 101 -G app -s /bin/sh -D app && \
apk update --no-cache -X https://mirror.yandex.ru/mirrors/alpine/v3.20/main && \
apk upgrade --no-cache -X https://mirror.yandex.ru/mirrors/alpine/v3.20/main
# place all necessary executables and other files into /app directory
WORKDIR /app/
RUN mkdir -p /app/bin
COPY --from=builder --chown=app:app /src/bin/ /app/bin/
# run container as new non-root user
USER app
CMD ["/app/bin/sgroups"]