From 86a6ebdb3a64d57896403f1e7fc3425317639a17 Mon Sep 17 00:00:00 2001 From: Velnbur Date: Wed, 5 Apr 2023 13:38:05 +0300 Subject: [PATCH 1/2] Add Dockerfile --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..23c7e3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM rust:1.67 as builder +WORKDIR /usr/src/service +COPY . . +RUN cargo install --path . + +FROM debian:bullseye-slim +RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/local/cargo/bin/service /usr/local/bin/service + +ENV CONFIG /etc/config.toml + +ENTRYPOINT ["service", "--config", "$CONFIG"] From 8d1e8f9c9f4bf262d66f9113fb3e30d6d763e4dd Mon Sep 17 00:00:00 2001 From: Velnbur Date: Wed, 5 Apr 2023 16:59:20 +0300 Subject: [PATCH 2/2] Add docker configs and action --- .dockerignore | 1 + .github/workflows/container-build.yaml | 38 ++++++++++++++++++++++++++ Dockerfile | 22 +++++++++++---- 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/container-build.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/target diff --git a/.github/workflows/container-build.yaml b/.github/workflows/container-build.yaml new file mode 100644 index 0000000..8e2a635 --- /dev/null +++ b/.github/workflows/container-build.yaml @@ -0,0 +1,38 @@ +name: Tag Docker Image with Git + +on: + push: + tags: [v*] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Log into the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push the Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 23c7e3a..5ec4aad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,24 @@ -FROM rust:1.67 as builder +FROM rust:1.67-buster as builder + WORKDIR /usr/src/service COPY . . -RUN cargo install --path . -FROM debian:bullseye-slim -RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/* +RUN apt-get update \ + && apt-get install -y protobuf-compiler python3 python3-pip + +RUN pip3 install solc-select \ + && solc-select install 0.8.19 \ + && solc-select use 0.8.19 + +# update cargo config to fetching with git cli +ENV CARGO_NET_GIT_FETCH_WITH_CLI true +RUN git config --global --add url."https://github.com/".insteadOf "git@github.com:" + +Run cargo install --verbose --path . + +FROM alpine:3.14 COPY --from=builder /usr/local/cargo/bin/service /usr/local/bin/service ENV CONFIG /etc/config.toml -ENTRYPOINT ["service", "--config", "$CONFIG"] +ENTRYPOINT ["service", "--config", "$CONFIG", "run"]