-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
34 lines (30 loc) · 1.03 KB
/
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
# syntax=docker/dockerfile:1.2
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:latest AS goreleaser-xx
FROM --platform=$BUILDPLATFORM golang:alpine AS base
COPY --from=goreleaser-xx / /
RUN apk add --no-cache git
WORKDIR /src
FROM base AS build
ARG TARGETPLATFORM
ARG GIT_REF
RUN --mount=type=bind,source=.,target=/src,rw \
goreleaser-xx --debug \
--name="discord-bot" \
--dist="/out" \
--hooks="go mod tidy" \
--hooks="go mod download" \
--ldflags="-s -w -X 'main.version={{.Version}}'" \
--files="LICENSE" \
--files="README.md"
FROM scratch AS artifact
COPY --from=build /out/*.tar.gz /
COPY --from=build /out/*.zip /
FROM alpine:3.20 AS image
RUN apk --update --no-cache add ca-certificates libressl shadow \
&& addgroup -g 1000 discord-bot \
&& adduser -u 1000 -G discord-bot -s /sbin/nologin -D discord-bot \
&& mkdir -p /var/log/discord-bot \
&& chown discord-bot. /var/log/discord-bot
COPY --from=build /usr/local/bin/discord-bot /usr/local/bin/discord-bot
USER discord-bot
ENTRYPOINT [ "discord-bot" ]