Skip to content

Instantly share code, notes, and snippets.

@mz2
Created March 27, 2017 16:04
Show Gist options
  • Save mz2/ae8b80fd06887d639a8992b988757e74 to your computer and use it in GitHub Desktop.
Save mz2/ae8b80fd06887d639a8992b988757e74 to your computer and use it in GitHub Desktop.
Development oriented Dockerfile for a Vapor app
# adapted from https://github.com/swiftdocker/docker-swift
# once docker-swift supports setting the swift version via a build-arg we could pull from there instead
FROM ubuntu:14.04
ENV SWIFT_BRANCH swift-3.0.2-release
ENV SWIFT_VERSION 3.0.2
ENV SWIFT_URL https://swift.org/builds/swift-3.0.2-release/ubuntu1404/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu14.04.tar.gz
ENV SWIFT_SIG_URL https://swift.org/builds/swift-3.0.2-release/ubuntu1404/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu14.04.tar.gz.sig
ENV SWIFT_PLATFORM ubuntu14.04
ENV SWIFT_ARCHIVE_NAME $SWIFT_VERSION-$SWIFT_PLATFORM
ENV SWIFT_ARCHIVE_TARBALL $SWIFT_ARCHIVE_NAME.tar.gz
ENV SWIFT_ARCHIVE_TARBALL_SIG $SWIFT_ARCHIVE_NAME.tar.gz.sig
# Install related packages and set LLVM 3.6 as the compiler
RUN apt-get update && \
apt-get install -y build-essential wget clang-3.6 curl libedit-dev python2.7 python2.7-dev libicu52 rsync libxml2 git libpq5 libpq-dev && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Swift keys
RUN wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import - && \
gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
# Install Swift Ubuntu 14.04 Snapshot
RUN wget $SWIFT_URL -O $SWIFT_ARCHIVE_TARBALL && \
wget $SWIFT_SIG_URL -O $SWIFT_ARCHIVE_TARBALL_SIG && \
gpg --verify $SWIFT_ARCHIVE_TARBALL_SIG && \
tar -xvzf $SWIFT_ARCHIVE_TARBALL --directory / --strip-components=1 && \
rm -rf $SWIFT_ARCHIVE_NAME* /tmp/* /var/tmp/*
# Set Swift Path
ENV PATH /usr/bin:$PATH
# vapor specific part
WORKDIR /vapor
VOLUME /vapor
EXPOSE 8080
# mount in local sources via: -v $(PWD):/vapor
# the vapor CLI command does this
CMD swift build && .build/debug/App --env=development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment