From 365c8ac52338c1be38e8714fa32b8c833787908f Mon Sep 17 00:00:00 2001 From: julien Date: Wed, 27 Nov 2024 21:03:44 +0100 Subject: [PATCH] feat: add docker build action --- .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 11 +++++----- 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7164602 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ github.sha }} + + clean: + name: Delete old images + needs: release + runs-on: ubuntu-latest + steps: + - uses: snok/container-retention-policy@v3.0.0 + with: + account: user + token: ${{ secrets.GITHUB_TOKEN }} + image-names: ${{ github.repository }} + cut-off: 4w + keep-n-most-recent: 5 diff --git a/docker-compose.yml b/docker-compose.yml index b462625..e229000 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,15 @@ -version: '3' services: webapp: - build: - context: . + image: ghcr.io/julienc91/ezshare:latest + pull_policy: always ports: - '127.0.0.1:3000:3000' + restart: always peerjs: - build: - context: . + image: ghcr.io/julienc91/ezshare:latest + pull_policy: always command: yarn peerjs --port 9000 ports: - '127.0.0.1:9000:9000' + restart: always