From 2d5a6dd076295915b94b5af6265eda812e240de2 Mon Sep 17 00:00:00 2001 From: Igor Vieira Date: Sat, 6 Apr 2024 20:16:38 -0300 Subject: [PATCH] heroku workflows --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ Dockerfile | 27 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..eab687b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: CI +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build Docker image + run: docker build -t registry.heroku.com/${{ secrets.HEROKU_APP }}/web:latest . + + - name: Docker image info + run: docker images + + - name: Login to container registry + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + run: heroku container:login + + - name: Push Docker image + run: docker push registry.heroku.com/${{ secrets.HEROKU_APP }}/web + + - name: Release + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + run: heroku container:release -a ${{ secrets.HEROKU_APP }} web diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0de013a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Use a Rust image with a specific version +FROM rust:1.60 as build + +# Set the working directory inside the container +WORKDIR /holy + +# Copy only the necessary files for dependency resolution +COPY ./Cargo.lock ./Cargo.lock +COPY ./Cargo.toml ./Cargo.toml + +# Build dependencies only (to cache them) +RUN cargo build --release + +# Copy the rest of your application source code +COPY ./src ./src + +# Build the application +RUN cargo build + +# Start a new build stage +FROM debian:buster-slim + +# Copy the built binary from the previous stage +COPY --from=build /holy/target/release/holy . + +# Set the command to run your binary +CMD ["./holy"]