diff --git a/Dockerfile-Swift5.3 b/Dockerfile-Swift5.3 new file mode 100644 index 0000000..083fe27 --- /dev/null +++ b/Dockerfile-Swift5.3 @@ -0,0 +1,5 @@ +FROM swift:5.3 + +RUN apt-get update && apt-get install -y libmysqlclient20 libmysqlclient-dev openssl libssl-dev libcurl4-openssl-dev + +CMD ["swift", "--version"] diff --git a/Hosting/Dockerfile-Swift5.3 b/Hosting/Dockerfile-Swift5.3 new file mode 100644 index 0000000..d16b4cf --- /dev/null +++ b/Hosting/Dockerfile-Swift5.3 @@ -0,0 +1,26 @@ +# Build image +FROM swift:5.3 as builder + +RUN apt-get -qq update && apt-get install -y \ + libssl-dev zlib1g-dev \ + && 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 -Xswiftc -g && mv `swift build -c release --show-bin-path` /build/bin + +# Run image +FROM ubuntu:18.04 + +# DEBIAN_FRONTEND=noninteractive for automatic UTC configuration in tzdata +RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + libatomic1 libicu60 libxml2 libcurl4 libz-dev libbsd0 tzdata libcurl4-openssl-dev \ + && rm -r /var/lib/apt/lists/* +WORKDIR /app +COPY --from=builder /build/bin/Run . +COPY --from=builder /build/lib/* /usr/lib/ +COPY --from=builder /app/Public ./Public +COPY --from=builder /app/Resources ./Resources +EXPOSE 8080 + +ENTRYPOINT ./Run serve --env production --hostname 0.0.0.0 --port 8080 diff --git a/README.md b/README.md index 9d58a79..6770be8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,10 @@ Currently we have the following images: - `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/) - `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". - `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". -- `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". +- `Dockerfile-Swift5` which is using Swift 5.0 and is supposed to be used for Vapor 3. The image is pushed to [here](https://hub.docker.com/r/nodesvapor/vapor-ci) with tag "swift-5.0". +- `Dockerfile-Swift5.1` which is using Swift 5.1 and is supposed to be used for Vapor 3. The image is pushed to [here](https://hub.docker.com/r/nodesvapor/vapor-ci) with tag "swift-5.1". +- `Dockerfile-Swift5.2` which is using Swift 5.2 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.2". +- `Dockerfile-Swift5.3` which is using Swift 5.3 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.3". ## 🛠 Updating the Docker images @@ -20,7 +23,8 @@ To make it easier to run a Vapor app through a Docker container, we have the fol - `Hosting/Dockerfile-Swift4.1` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. - `Hosting/Dockerfile-Swift4.2` which is using Swift 4.2 and is supposed to be used for Vapor 2 or Vapor 3 projects. -- `Hosting/Dockerfile-Swift5.0` which is using Swift 5.0 and is supposed to be used for Vapor 3 or Vapor 4 projects. +- `Hosting/Dockerfile-Swift5.0` which is using Swift 5.0 and is supposed to be used for Vapor 3 projects. +- `Hosting/Dockerfile-Swift5.3` which is using Swift 5.3 and is supposed to be used for Vapor 3 or Vapor 4 projects. Further, we have the following Docker Compose files for spinning up full environments including database and Redis: @@ -31,7 +35,9 @@ Further, we have the following Docker Compose files for spinning up full environ To make it easier to test Vapor apps locally on Linux using Docker, we have made the following Dockerfiles: - `Testing/Dockerfile-Swift4.1` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. -- `Testing/Dockerfile-Swift4.2` which is using Swift 4.1 and is supposed to be used for Vapor 2 or Vapor 3 projects. +- `Testing/Dockerfile-Swift4.2` which is using Swift 4.2 and is supposed to be used for Vapor 2 or Vapor 3 projects. +- `Testing/Dockerfile-Swift5.0` which is using Swift 5.0 and is supposed to be used for Vapor 3 projects. +- `Testing/Dockerfile-Swift5.3` which is using Swift 5.3 and is supposed to be used for Vapor 3 or Vapor 4 projects. ## 🌳 Environment variables diff --git a/Testing/Dockerfile-Swift5.3 b/Testing/Dockerfile-Swift5.3 new file mode 100644 index 0000000..c93c26b --- /dev/null +++ b/Testing/Dockerfile-Swift5.3 @@ -0,0 +1,15 @@ +FROM swift:5.3 +WORKDIR /package +COPY . ./ + +RUN apt-get update && apt-get install -y wget apt-transport-https software-properties-common && \ +wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | apt-key add - && \ +echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/vapor.list && \ +apt-get update && \ +apt-get install -y libmysqlclient20 libmysqlclient-dev cstack ctls openssl libssl-dev libcurl4-openssl-dev + +RUN swift package resolve +RUN swift package clean + +CMD ["swift", "--version"] +CMD ["swift", "test"]