-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
43 lines (31 loc) · 953 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
# Based on recipie described here:
# https://chemidy.medium.com/create-the-smallest-and-secured-golang-docker-image-based-on-scratch-4752223b7324
# BUILDER IMAGE
############################
FROM golang:1.21-alpine3.18 AS builder
# Git is required for fetching the dependencies
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY . .
RUN go get -d -v
RUN GOOS=linux go build -ldflags="-w -s" -o freefeed-tg-client
# PRODUCTION IMAGE
############################
FROM alpine:3.18
WORKDIR /bot
VOLUME /bot/data
ENV UID 10001
ENV GID 10001
ENV TOKEN ""
ENV DEBUG ""
# Create unprivileged user
RUN addgroup -g "${GID}" bot && \
adduser -g "" -s /bin/false -G bot -D -H -u "${UID}" bot && \
mkdir -p data && \
chown bot:bot data
# Copy our static executable
COPY --from=builder /app/freefeed-tg-client .
# Use an unprivileged user
USER bot:bot
# Run the app binary
ENTRYPOINT ./freefeed-tg-client -token "${TOKEN}" -debug "${DEBUG}"