-
Notifications
You must be signed in to change notification settings - Fork 77
/
Dockerfile
44 lines (34 loc) · 1.34 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
# ================================
# Build image
# ================================
FROM swift:5.7-focal as build
WORKDIR /build
# Install libraries needed
RUN apt-get -qq update && apt-get install -y \
libssl-dev zlib1g-dev
# First just resolve dependencies.
# This creates a cached layer that can be reused
# as long as your Package.swift/Package.resolved
# files do not change.
COPY ./Package.* ./
RUN swift package resolve
# Copy entire repo into container
COPY . .
# Compile with optimizations
RUN swift build --enable-test-discovery --product XCMetricsBackend -c release
# ================================
# Run image
# ================================
FROM swift:5.7-focal-slim
# Create a vapor user and group with /app as its home directory
RUN useradd --user-group --create-home --home-dir /app vapor
WORKDIR /app
# Copy build artifacts
COPY --from=build --chown=vapor:vapor /build/.build/release /app
# Uncomment the next line if you need to load resources from the `Public` directory
#COPY --from=build --chown=vapor:vapor /build/Public /app/Public
# Ensure all further commands run as the vapor user
USER vapor
# Start the Vapor service when the image is run, default to listening on 8080 in production environment
ENTRYPOINT ["./XCMetricsBackend"]
CMD ["serve", "--auto-migrate", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]