generated from lazybytez/general-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (41 loc) · 1.65 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# First build application
FROM golang:1.22-alpine
ARG app_version="edge"
ARG build_commit_sha=""
ENV APP_VERSION=$app_version
ENV BUILD_COMMIT_SHA=$build_commit_sha
RUN mkdir -p /app
WORKDIR /app
# Install necessary dependencies
RUN apk update && apk upgrade && apk add g++
# Pre-download to enable dependency caching
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# Copy source and start build
COPY . .
RUN go install github.com/swaggo/swag/cmd/swag@latest && swag init
RUN go build -ldflags "-X github.com/lazybytez/jojo-discord-bot/build.Version=${APP_VERSION} -X github.com/lazybytez/jojo-discord-bot/build.CommitSHA=${BUILD_COMMIT_SHA}" -v -o /app ./...
# Throw away last step and put binary in basic alpine image
FROM alpine:latest
RUN apk add --no-cache iputils setpriv dumb-init && rm -rf /root/.cache
RUN mkdir -p /app
WORKDIR /app
COPY --from=0 /app/jojo-discord-bot jojo-discord-bot
COPY ./scripts/entrypoint.sh /usr/bin/entrypoint.sh
COPY ./app.json /app/app.json
RUN chmod 755 jojo-discord-bot
RUN chmod 755 /usr/bin/entrypoint.sh
VOLUME ["/app/data", "/app/log"]
# General image informations
LABEL author="Lazy Bytez"
LABEL maintainer="[email protected]"
# Open Container annotations
LABEL org.opencontainers.image.title="JOJO Discord Bot"
LABEL org.opencontainers.image.description="An advanced multi-purpose discord bot"
LABEL org.opencontainers.image.vendor="Lazy Bytez"
LABEL org.opencontainers.image.source="https://github.com/lazybytez/jojo-discord-bot"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
# Default port for WebAPI
EXPOSE 8080
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/bin/entrypoint.sh"]
CMD ["/app/jojo-discord-bot"]