├── Dockerfile-Swift5.1 ├── Dockerfile-Swift5.2 ├── Dockerfile-Swift3 ├── Dockerfile-Swift4 ├── Dockerfile-Swift5.0 ├── Dockerfile-Swift4.2 ├── Dockerfile-Swift4.1 ├── Testing ├── Dockerfile-Swift5.1 ├── Dockerfile-Swift4.1 └── Dockerfile-Swift4.2 ├── Hosting ├── docker-compose-mysql.yml ├── Dockerfile-Swift5.0 ├── Dockerfile-Swift4.2 └── Dockerfile-Swift4.1 ├── LICENSE └── README.md /Dockerfile-Swift5.1: -------------------------------------------------------------------------------- 1 | FROM swift:5.1 2 | 3 | RUN apt-get update && apt-get install -y libmysqlclient20 libmysqlclient-dev openssl libssl-dev libcurl4-openssl-dev 4 | 5 | CMD ["swift", "--version"] 6 | -------------------------------------------------------------------------------- /Dockerfile-Swift5.2: -------------------------------------------------------------------------------- 1 | FROM swift:5.2 2 | 3 | RUN apt-get update && apt-get install -y libmysqlclient20 libmysqlclient-dev openssl libssl-dev libcurl4-openssl-dev 4 | 5 | CMD ["swift", "--version"] 6 | -------------------------------------------------------------------------------- /Dockerfile-Swift3: -------------------------------------------------------------------------------- 1 | FROM swift:3 2 | 3 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 4 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 5 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 6 | apt-get update && \ 7 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack 8 | 9 | CMD ["swift", "--version"] -------------------------------------------------------------------------------- /Dockerfile-Swift4: -------------------------------------------------------------------------------- 1 | FROM swift:4 2 | 3 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 4 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 5 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 6 | apt-get update && \ 7 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack libcurl4-openssl-dev 8 | 9 | CMD ["swift", "--version"] -------------------------------------------------------------------------------- /Dockerfile-Swift5.0: -------------------------------------------------------------------------------- 1 | FROM swift:5.0 2 | 3 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common && \ 4 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 5 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 6 | apt-get update && \ 7 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 8 | 9 | CMD ["swift", "--version"] 10 | -------------------------------------------------------------------------------- /Dockerfile-Swift4.2: -------------------------------------------------------------------------------- 1 | FROM swift:4.2.2 2 | 3 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 4 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 5 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 6 | apt-get update && \ 7 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 8 | 9 | CMD ["swift", "--version"] 10 | -------------------------------------------------------------------------------- /Dockerfile-Swift4.1: -------------------------------------------------------------------------------- 1 | FROM norionomura/swift:swift-4.1-branch 2 | 3 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 4 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 5 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 6 | apt-get update && \ 7 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 8 | 9 | CMD ["swift", "--version"] 10 | -------------------------------------------------------------------------------- /Testing/Dockerfile-Swift5.1: -------------------------------------------------------------------------------- 1 | FROM swift:5.1 2 | WORKDIR /package 3 | COPY . ./ 4 | 5 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common && \ 6 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 7 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 8 | apt-get update && \ 9 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 10 | 11 | RUN swift package resolve 12 | RUN swift package clean 13 | 14 | CMD ["swift", "--version"] 15 | CMD ["swift", "test"] 16 | -------------------------------------------------------------------------------- /Testing/Dockerfile-Swift4.1: -------------------------------------------------------------------------------- 1 | FROM swift:4.1 2 | WORKDIR /package 3 | COPY . ./ 4 | 5 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 6 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 7 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 8 | apt-get update && \ 9 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 10 | 11 | RUN swift package resolve 12 | RUN swift package clean 13 | 14 | CMD ["swift", "--version"] 15 | CMD ["swift", "test"] -------------------------------------------------------------------------------- /Testing/Dockerfile-Swift4.2: -------------------------------------------------------------------------------- 1 | FROM swift:4.2.2 2 | WORKDIR /package 3 | COPY . ./ 4 | 5 | RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common python-software-properties && \ 6 | wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ 7 | echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ 8 | apt-get update && \ 9 | apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev 10 | 11 | RUN swift package resolve 12 | RUN swift package clean 13 | 14 | CMD ["swift", "--version"] 15 | CMD ["swift", "test"] -------------------------------------------------------------------------------- /Hosting/docker-compose-mysql.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | vapor: 4 | depends_on: 5 | - mysql 6 | - redis 7 | build: . 8 | environment: 9 | - DATABASE_HOSTNAME=mysql 10 | - DATABASE_PORT=3306 11 | - DATABASE_USERNAME=vapor 12 | - DATABASE_PASSWORD=password 13 | - DATABASE_DB=vapor 14 | - REDIS_HOSTNAME=redis 15 | ports: 16 | - 8088:8080 17 | mysql: 18 | image: "mysql:5.7" 19 | restart: always 20 | environment: 21 | - MYSQL_DATABASE=vapor 22 | - MYSQL_USER=vapor 23 | - MYSQL_PASSWORD=password 24 | - MYSQL_ROOT_PASSWORD=password 25 | ports: 26 | - 33306:3306 27 | redis: 28 | image: "redis:alpine" -------------------------------------------------------------------------------- /Hosting/Dockerfile-Swift5.0: -------------------------------------------------------------------------------- 1 | # Build image 2 | FROM swift:5.0 as builder 3 | 4 | RUN apt-get -qq update && apt-get install -y \ 5 | libssl-dev zlib1g-dev \ 6 | && rm -r /var/lib/apt/lists/* 7 | WORKDIR /app 8 | COPY . . 9 | RUN mkdir -p /build/lib && cp -R /usr/lib/swift/linux/*.so* /build/lib 10 | RUN swift build -c release -Xswiftc -g && mv `swift build -c release --show-bin-path` /build/bin 11 | 12 | # Run image 13 | FROM ubuntu:18.04 14 | 15 | # DEBIAN_FRONTEND=noninteractive for automatic UTC configuration in tzdata 16 | RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ 17 | libatomic1 libicu60 libxml2 libcurl4 libz-dev libbsd0 tzdata libcurl4-openssl-dev \ 18 | && rm -r /var/lib/apt/lists/* 19 | WORKDIR /app 20 | COPY --from=builder /build/bin/Run . 21 | COPY --from=builder /build/lib/* /usr/lib/ 22 | COPY --from=builder /app/Public ./Public 23 | COPY --from=builder /app/Resources ./Resources 24 | EXPOSE 8080 25 | 26 | ENTRYPOINT ./Run serve --env production --hostname 0.0.0.0 --port 8080 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2018 Nodes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Hosting/Dockerfile-Swift4.2: -------------------------------------------------------------------------------- 1 | # Remember to pick the correct Swift version 2 | FROM swift:4.2.2 as builder 3 | WORKDIR /app/ 4 | COPY . . 5 | 6 | # Install any dependencies there might be 7 | RUN \ 8 | apt-get -q update && apt-get -q -y install \ 9 | libmysqlclient-dev \ 10 | && rm -r /var/lib/apt/lists/* 11 | 12 | # Build the artifacts 13 | RUN mkdir -p /build/lib && cp -R /usr/lib/swift/linux/*.so /build/lib 14 | RUN bash -c "swift build -c release && mv `swift build -c release --show-bin-path` /build/bin" 15 | 16 | # Setup new machine to run the artifacts 17 | FROM ubuntu:16.04 18 | 19 | # Install any dependencies there might be 20 | RUN \ 21 | apt-get -q update && apt-get -q -y install \ 22 | libatomic1 \ 23 | libbsd0 \ 24 | libcurl4 \ 25 | libicu55 \ 26 | libmysqlclient20 \ 27 | libxml2 \ 28 | libcurl4-openssl-dev \ 29 | && rm -r /var/lib/apt/lists/* 30 | WORKDIR /app/ 31 | COPY --from=builder /build/bin . 32 | COPY --from=builder /build/lib/* /usr/lib/ 33 | COPY --from=builder /app/Resources ./Resources 34 | COPY --from=builder /app/Public ./Public 35 | EXPOSE 8080 36 | 37 | CMD ["./Run","--env=production","--port=8080","--hostname=0.0.0.0"] 38 | -------------------------------------------------------------------------------- /Hosting/Dockerfile-Swift4.1: -------------------------------------------------------------------------------- 1 | # Remember to pick the correct Swift version 2 | FROM swift:4.1 as builder 3 | WORKDIR /app/ 4 | COPY . . 5 | 6 | # Install any dependencies there might be 7 | RUN \ 8 | apt-get -q update && apt-get -q -y install \ 9 | libmysqlclient-dev \ 10 | && rm -r /var/lib/apt/lists/* 11 | 12 | # Build the artifacts 13 | RUN mkdir -p /build/lib && cp -R /usr/lib/swift/linux/*.so /build/lib 14 | RUN bash -c "swift build -c release && mv `swift build -c release --show-bin-path` /build/bin" 15 | 16 | # Setup new machine to run the artifacts 17 | FROM ubuntu:16.04 18 | 19 | # Install any dependencies there might be 20 | RUN \ 21 | apt-get -q update && apt-get -q -y install \ 22 | libatomic1 \ 23 | libbsd0 \ 24 | libcurl4 \ 25 | libicu55 \ 26 | libmysqlclient20 \ 27 | libxml2 \ 28 | libcurl4-openssl-dev \ 29 | && rm -r /var/lib/apt/lists/* 30 | WORKDIR /app/ 31 | COPY --from=builder /build/bin . 32 | COPY --from=builder /build/lib/* /usr/lib/ 33 | COPY --from=builder /app/Config ./Config 34 | COPY --from=builder /app/Resources ./Resources 35 | COPY --from=builder /app/Public ./Public 36 | EXPOSE 8080 37 | 38 | CMD ["./Run","--env=production","--port=8080","--hostname=0.0.0.0"] 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerfiles 🐳 2 | 3 | Dockerfiles that ships with dependencies for running Vapor projects (including [CStack](https://github.com/nodes-vapor/cstack)) on Linux. These images are used in [our Circle CI scripts](https://github.com/nodes-vapor/readme/tree/master/Configuration/.circleci). 4 | 5 | Currently we have the following images: 6 | 7 | - `Dockerfile-Swift3` which is using Swift 3 and is supposed to be used for Vapor 1 projects. The image is pushed to [here](https://hub.docker.com/r/brettrtoomey/vapor1-ci/). 8 | - `Dockerfile-Swift4` which is using Swift 4 and is supposed to be used for Vapor 2 projects. The image is pushed to [here](https://hub.docker.com/r/brettrtoomey/vapor-ci/) 9 | - `Dockerfile-Swift4.1` which is using Swift 4.1 and is supposed to be used for Vapor 2 or 3 projects. The image is pushed to [here](https://hub.docker.com/r/nodesvapor/vapor-ci) with tag "swift-4.1". 10 | - `Dockerfile-Swift4.2` which is using Swift 4.2 (release) and is supposed to be used for Vapor 2 or 3 projects. The image is pushed to [here](https://hub.docker.com/r/nodesvapor/vapor-ci) with tag "swift-4.2". 11 | - `Dockerfile-Swift5` which is using Swift 5.0 and is supposed to be used for Vapor 3 or 4 projects. The image is pushed to [here](https://hub.docker.com/r/nodesvapor/vapor-ci) with tag "swift-5.0". 12 | 13 | ## 🛠 Updating the Docker images 14 | 15 | A guide for building new images based on Dockerfiles can be found [here](https://circleci.com/docs/2.0/custom-images/). 16 | 17 | ## ☁️ Hosting 18 | 19 | To make it easier to run a Vapor app through a Docker container, we have the following Dockerfiles for guidance: 20 | 21 | - `Hosting/Dockerfile-Swift4.1` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. 22 | - `Hosting/Dockerfile-Swift4.2` which is using Swift 4.2 and is supposed to be used for Vapor 2 or Vapor 3 projects. 23 | - `Hosting/Dockerfile-Swift5.0` which is using Swift 5.0 and is supposed to be used for Vapor 3 or Vapor 4 projects. 24 | 25 | Further, we have the following Docker Compose files for spinning up full environments including database and Redis: 26 | 27 | - `Hosting/docker-compose-mysql.yml` which is using MySQL 5.7 and the latest version of Redis. 28 | 29 | ## 👌 Testing 30 | 31 | To make it easier to test Vapor apps locally on Linux using Docker, we have made the following Dockerfiles: 32 | 33 | - `Testing/Dockerfile-Swift4.1` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. 34 | - `Testing/Dockerfile-Swift4.2` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. 35 | 36 | ## 🌳 Environment variables 37 | 38 | Environment variables are supported in Docker. Please read the [docs regarding environment variables](https://docs.docker.com/compose/environment-variables/) for info regarding how to configure them. 39 | 40 | In short composer prioritizes environment variables in the following order: 41 | 42 | 1. Compose file 43 | 2. Shell environment variables 44 | 3. Environment file 45 | 4. Dockerfile 46 | 5. Variable is not defined 47 | 48 | If you want to use a `.env`-file, make sure to remove the environment section in your docker-compose file as described in the docs, referenced above. 49 | 50 | ## 🏆 Credits 51 | 52 | This package is developed and maintained by the Vapor team at [Nodes](https://www.nodesagency.com). 53 | The package owner for this project is [Steffen](https://github.com/steffendsommer). 54 | 55 | ## 📄 License 56 | 57 | This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) 58 | --------------------------------------------------------------------------------