diff --git a/.github/workflows/create-n-publish-to-docker.yaml b/.github/workflows/create-n-publish-to-docker.yaml new file mode 100644 index 0000000..fef6923 --- /dev/null +++ b/.github/workflows/create-n-publish-to-docker.yaml @@ -0,0 +1,51 @@ +name: Create and publish a Docker image + +on: + release: + types: [released] + +env: + USERNAME: streamware + IMAGE_NAME: pulse-cast + + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.USERNAME }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7122586 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM rust:1.79 as builder + +WORKDIR /app + +COPY . /app + +RUN apt-get update +RUN apt-get install protobuf-compiler -y + +RUN cargo build --release + +FROM rust:1.79 + +COPY --from=builder \ + /app/target/release/pulse-cast \ + /usr/local/bin/ + +EXPOSE 8080 + +CMD ["/usr/local/bin/pulse-cast"] \ No newline at end of file