-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (32 loc) · 1.18 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (32 loc) · 1.18 KB
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
# This is a multi-stage Dockerfile and requires >= Docker 17.05
# https://docs.docker.com/engine/userguide/eng-image/multistage-build/
FROM swift:6.3-jammy AS builder
WORKDIR /build
# Resolve dependencies before copying source, so source-only changes don't invalidate the
# downloaded-dependencies layer.
COPY Package.swift Package.resolved* ./
RUN swift package resolve
COPY . .
RUN swift build -c release --static-swift-stdlib
FROM swift:6.3-jammy-slim
ARG USERNAME=sweetrpg
ARG BUILD_NUMBER=unset
ARG BUILD_JOB=unset
ARG BUILD_SHA=unset
ARG BUILD_DATE=unset
ARG BUILD_VERSION=unset
RUN useradd --user-group --create-home --system --skel /dev/null $USERNAME
WORKDIR /app
RUN mkdir -p /app/bin /app/config
COPY --from=builder /build/.build/release/App /app/bin/
COPY --from=builder /build/Resources /app/Resources
RUN echo "{\"number\":\"${BUILD_NUMBER}\",\"job\":\"${BUILD_JOB}\",\"sha\":\"${BUILD_SHA}\",\"date\":\"${BUILD_DATE}\",\"version\":\"${BUILD_VERSION}\"}" > /app/config/build-info.json
RUN chown -R ${USERNAME}:${USERNAME} /app
ENV PORT="8080"
ENV REDIS_HOST=""
ENV REDIS_PORT="6379"
ENV VERSION=${BUILD_VERSION}
EXPOSE 8080
USER ${USERNAME}
ENTRYPOINT ["/app/bin/App"]
CMD ["serve"]