Skip to content

Commit

Permalink
feat: add docker file and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
delbertbeta committed Sep 28, 2024
1 parent b9f6341 commit c8c8d44
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: build-and-publish

on:
push:
branches:
- "main"
- "feat/docker-build"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ vars.DOCKERHUB_USERNAME }}/sso-rs

- name: Build and push
uses: docker/build-push-action@v6
id: push
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ vars.DOCKERHUB_USERNAME }}/sso-rs
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.77 AS builder
COPY . .
RUN cargo build --release
COPY ./target/release/sso-rs /sso-rs

FROM alpine:3.20.3
COPY --from=builder /sso-rs /sso-rs
EXPOSE 3000
EXPOSE 2999
CMD ["/sso-rs"]

0 comments on commit c8c8d44

Please sign in to comment.