Skip to content

Instantly share code, notes, and snippets.

@standinga
Created April 12, 2019 15:47
Show Gist options
  • Save standinga/62fdb5c5f84c2ebe62080f076c533c07 to your computer and use it in GitHub Desktop.
Save standinga/62fdb5c5f84c2ebe62080f076c533c07 to your computer and use it in GitHub Desktop.
web.Dockerfile from Vapor template modified to be able to read .env from docker-compose
# You can set the Swift version to what you need for your app. Versions can be found here: https://hub.docker.com/_/swift
FROM swift:4.2 as builder
ARG env
RUN apt-get -qq update && apt-get -q -y install \
tzdata \
&& rm -r /var/lib/apt/lists/*
WORKDIR /app
COPY . .
RUN mkdir -p /build/lib && cp -R /usr/lib/swift/linux/*.so /build/lib
RUN swift build -c release && mv `swift build -c release --show-bin-path` /build/bin
# Production image
FROM ubuntu:16.04
ARG env
RUN apt-get -qq update && apt-get install -y \
libicu55 libxml2 libbsd0 libcurl3 libatomic1 \
tzdata \
&& rm -r /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /build/bin/Run .
COPY --from=builder /build/lib/* /usr/lib/
ENTRYPOINT ./Run serve -e prod -b 0.0.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment