From f184566d1a59e5a8d10293ea8b548a2ce383c15f Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Fri, 23 Oct 2020 19:13:25 +0200 Subject: [PATCH] Setup CD: Docker image and action to push to GH container registry (#61) --- .dockerignore | 3 +++ .github/workflows/deployment.yml | 30 ++++++++++++++++++++++++++ Dockerfile | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/deployment.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..df78a06 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/target +/Dockerfile +/.qovery.yml diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..cf15145 --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,30 @@ +name: Deployment + +on: + push: + branches: [main] + +jobs: + build-docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5e690f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM buildpack-deps:buster as build + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +COPY rust-toolchain /src/ + +RUN set -eux; \ + \ + url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \ + wget "$url"; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --default-toolchain $(cat /src/rust-toolchain); \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; + +COPY . /src +RUN cargo install --path /src + +FROM debian:buster + +LABEL org.opencontainers.image.source https://github.com/deps-rs/deps.rs + +RUN set -ex; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y --no-install-recommends libssl-dev; \ + rm -rf /var/lib/apt/lists/* + +COPY --from=build /usr/local/cargo/bin/shiny-robots /usr/local/bin + +EXPOSE 8080 +CMD /usr/local/bin/shiny-robots