-
-
Notifications
You must be signed in to change notification settings - Fork 168
/
Dockerfile
43 lines (32 loc) · 817 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
35
36
37
38
39
40
41
42
43
FROM golang:latest-bullseye AS builder
# Build Args
ARG BUILD_COMMAND="go build -o metabigor ."
ARG BINARY_NAME="metabigor"
ARG CGO_ENABLED="0"
# Env setup
ENV CGO_ENABLED=${CGO_ENABLED}
# Setup workdir
WORKDIR /build
# Copy source code
COPY . .
# Fetch dependencies
RUN apt install build-essential
RUN go mod download
RUN go build -o ${BINARY_NAME} .
# Runner stage
FROM golang:latest-alpine AS runner
# Build Args
ARG BINARY_NAME="metabigor"
ARG START_COMMAND="./metabigor"
# Setup workdir
WORKDIR /app
RUN useradd -D metabigor
RUN chown -R metabigor:metabigor /app
# Copy binary
COPY --from=builder /build/${BINARY_NAME} .
# Create entrypoint
RUN echo ${START_COMMAND} > /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
USER metabigor
# Setup Entrypoint
ENTRYPOINT ["sh", "-c", "/user/entrypoint.sh"]