构建swift镜像
进入vapor目录(如果没有就创建其目录。)
cd ~/tmp/vapor/
在
vapor
目录下创建并编辑Dockerfile
配置文件
FROM ubuntu:16.04 LABEL maintainer="Jeremy <veci@aliyun.com>"LABEL description="Docker container for Swift Vapor development"# Install related packagesRUN apt-get update && apt-get upgrade -y && \ apt-get install -y \ git \ curl \ cmake \ wget \ ninja-build \ clang \ python \ uuid-dev \ libicu-dev \ icu-devtools \ libbsd-dev \ libedit-dev \ libxml2-dev \ libsqlite3-dev \ swig \ libpython-dev \ libncurses5-dev \ pkg-config \ libblocksruntime-dev \ libcurl4-openssl-dev \ systemtap-sdt-dev \ tzdata \ rsync && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*# Swift down URL pattern:# https://swift.org/builds/swift-4.1.2-release/ubuntu1604/swift-4.1.2-RELEASE/swift-4.1.2-RELEASE-ubuntu16.04.tar.gzARG SWIFT_PLATFORM=ubuntu16.04 ARG SWIFT_BRANCH=swift-4.1.2-release ARG SWIFT_VERSION=swift-4.1.2-RELEASE ENV SWIFT_PLATFORM=$SWIFT_PLATFORM \ SWIFT_BRANCH=$SWIFT_BRANCH \ SWIFT_VERSION=$SWIFT_VERSION# Download the binary and sig files, check the signature, unzip the package and set the correct priviledge.RUN SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz \ && curl -fSsL $SWIFT_URL -o swift.tar.gz \ && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig \ && export GNUPGHOME="$(mktemp -d)" \ && set -e; gpg --quiet --keyserver ha.pool.sks-keyservers.net \ --recv-keys "5E4DF843FB065D7F7E24FBA2EF5430F071E1B235"; \ gpg --batch --verify --quiet swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory / --strip-components=1 \ && chmod -R o+r /usr/lib/swift \ && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz RUN swift --version
以上是构建在Ubuntu16.04环境下的4.1.2的swift镜像。也可以在Swift.org中构建最新的等.
注意上面keys的改变。
构建镜像
docker build -t veniveci/swift:0.1.0 .
运行镜像
docker run --privileged -it veniveci/swift:0.1.0 swift
运行完之后
Ctrl + D
退出交互
构建Vapor镜像
进入vapor目录
cd ~/tmp/vapor/
创建并编辑
DockerFile_Vapor
配置文件
FROM ubuntu:16.04 LABEL maintainer="Jeremy <veci@aliyun.com>"LABEL description="Docker container for Swift Vapor development"# Install related packagesRUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y \ git \ curl \ wget \ cmake \ ninja-build \ clang \ python \ uuid-dev \ libicu-dev \ icu-devtools \ libbsd-dev \ libedit-dev \ libxml2-dev \ libsqlite3-dev \ swig \ libpython-dev \ libncurses5-dev \ pkg-config \ libblocksruntime-dev \ libcurl4-openssl-dev \ systemtap-sdt-dev \ tzdata \ rsync && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*# Vapor setupRUN /bin/bash -c "$(wget -qO- https://apt.vapor.sh)"# Install vapor and cleanRUN apt-get install swift vapor -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN vapor --help
构建vapor镜像
docker build -f ./DockerFile_Vapor -t veniveci/vapor:0.1.0 .
作者:Jeremy_L_Wang
链接:https://www.jianshu.com/p/d9236315ab65