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 new file mode 100644 index 0000000..5ec4aad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM rust:1.67-buster as builder + +WORKDIR /usr/src/service +COPY . . + +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", "run"]