Skip to content

Commit

Permalink
Merge pull request #7 from streamware/build/implement-github-actions-…
Browse files Browse the repository at this point in the history
…for-pushing-docker

Build/implement GitHub actions for pushing docker
  • Loading branch information
Hasan Haghniya authored Jul 5, 2024
2 parents 398b829 + 2c7bb37 commit 72caeb0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/create-n-publish-to-docker.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 72caeb0

Please sign in to comment.