From e1154298a5417c2ecb1f78ff9c31b9cf06579147 Mon Sep 17 00:00:00 2001 From: delbertbeta Date: Sat, 28 Sep 2024 23:20:59 +0800 Subject: [PATCH] feat: add docker file and github actions --- .github/workflows/build.yaml | 41 ++++++++++++++++++++++++++++++++++++ Dockerfile | 5 +++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..0246872 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,41 @@ +name: build-and-publish + +on: + push: + branches: + - "main" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build binary + run: cargo build --release + + - 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 }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1a76a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:3.20.3 +COPY ./target/release/sso-rs /sso-rs +EXPOSE 3000 +EXPOSE 2999 +CMD ["/sso-rs"]