-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
34 lines (22 loc) · 928 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
34
FROM golang:1.21-alpine3.18 AS builder
ARG BUILD_VERSION
ARG BUILD_HASH
RUN test -n "${BUILD_VERSION}" || (echo "Build argument BUILD_VERSION is required but not provided" && exit 1)
WORKDIR /app
COPY . ./
RUN cp examples/config.multiple.yml ./config.example.yml && \
go test ./... && \
go build -ldflags="-X main.version=${BUILD_VERSION} -X main.commitHash=${BUILD_HASH:0:7}" -o tesla-geogdo cmd/app/main.go
FROM alpine:3.18
ARG USER_UID=10000
ARG USER_GID=$USER_UID
VOLUME [ "/app/config" ]
WORKDIR /app
RUN apk add --no-cache bash tzdata && \
addgroup --gid $USER_GID nonroot && \
adduser --uid $USER_UID --ingroup nonroot --system --shell bin/bash nonroot && \
chown -R nonroot:nonroot /app
COPY --from=builder --chown=nonroot:nonroot --chmod=755 /app/tesla-geogdo /app/config.example.yml /app/
ENV PATH="/app:${PATH}"
USER nonroot
CMD [ "/app/tesla-geogdo", "-c", "/app/config/config.yml" ]