From 1403a756f78e316f3bd77913a528833b3507c724 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji Date: Fri, 22 Nov 2024 16:52:23 -0600 Subject: [PATCH] Dockerify --- .../workflows/{fly-deploy.yml => deploy.yml} | 0 Dockerfile | 1 - docker-compose.dev.yml | 4 +-- docker-compose.yml | 35 +++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) rename .github/workflows/{fly-deploy.yml => deploy.yml} (100%) create mode 100644 docker-compose.yml diff --git a/.github/workflows/fly-deploy.yml b/.github/workflows/deploy.yml similarity index 100% rename from .github/workflows/fly-deploy.yml rename to .github/workflows/deploy.yml diff --git a/Dockerfile b/Dockerfile index 6b7a33b..55fd29a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,6 @@ RUN go mod download COPY . . -# Note: CGO_ENABLED=1 is default, so we don't need to explicitly set it RUN go build -ldflags="-s -w" -o /go/bin/app # Final stage diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 047b861..b8c756c 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,5 +1,3 @@ -version: "3" - services: app: build: @@ -10,4 +8,4 @@ services: pull_policy: build environment: - DISCORD_TOKEN=$DISCORD_TOKEN - - COOLDOWN_ALLOW_LIST=$COOLDOWN_ALLOW_LIST \ No newline at end of file + - COOLDOWN_ALLOW_LIST=$COOLDOWN_ALLOW_LIST diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..abea909 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +name: Docker Deploy +on: + push: + branches: [main] + pull_request: + branches: [main] +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.REPO_HOST }} + username: ${{ github.repository_owner }} + password: ${{ secrets.DEPLOY_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} + ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest