forked from open-meteo/open-meteo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (37 loc) · 1.78 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
# ================================
# Build image contains swift compiler and libraries like netcdf or eccodes
# ================================
FROM ghcr.io/open-meteo/docker-container-build:latest as build
WORKDIR /build
# 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 MARCH_SKYLAKE=TRUE swift build -c release
# ================================
# Run image contains swift runtime libraries, netcdf, eccodes, cdo and cds utilities
# ================================
FROM ghcr.io/open-meteo/docker-container-run:latest
# Create a openmeteo user and group with /app as its home directory
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app openmeteo
# Switch to the new home directory
WORKDIR /app
# Copy build artifacts
COPY --from=build --chown=openmeteo:openmeteo /build/.build/release/openmeteo-api /app
RUN mkdir -p /app/Resources
# COPY --from=build --chown=openmeteo:openmeteo /build/Resources /app/Resources
COPY --from=build --chown=openmeteo:openmeteo /build/.build/release/SwiftTimeZoneLookup_SwiftTimeZoneLookup.resources /app/Resources/SwiftTimeZoneLookup_SwiftTimeZoneLookup.resources
COPY --from=build --chown=openmeteo:openmeteo /build/Public /app/Public
# Attach a volumne
RUN mkdir /app/data && chown openmeteo:openmeteo /app/data
VOLUME /app/data
# Ensure all further commands run as the openmeteo user
USER openmeteo:openmeteo
# Start the service when the image is run, default to listening on 8080 in production environment
ENTRYPOINT ["./openmeteo-api"]
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]