diff --git a/Dockerfile b/.build/Dockerfile similarity index 86% rename from Dockerfile rename to .build/Dockerfile index eeb68f3..80cd504 100644 --- a/Dockerfile +++ b/.build/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23-alpine AS builder +FROM golang:1.26-alpine AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..64087af --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,49 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [main] + tags: ["v*"] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: .build/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index cf87462..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,62 +0,0 @@ -services: - app: - build: . - env_file: .env - ports: - - "8080:8080" - depends_on: - postgres: - condition: service_healthy - redis: - condition: service_healthy - restart: unless-stopped - - postgres: - image: postgres:16-alpine - environment: - POSTGRES_USER: tower - POSTGRES_PASSWORD: tower - POSTGRES_DB: tower - volumes: - - postgres_data:/var/lib/postgresql/data - - ./db/migrations:/docker-entrypoint-initdb.d:ro - ports: - - "5432:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U tower"] - interval: 5s - timeout: 5s - retries: 5 - restart: unless-stopped - - redis: - image: redis:7-alpine - volumes: - - redis_data:/data - ports: - - "6379:6379" - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 5s - timeout: 5s - retries: 5 - restart: unless-stopped - - caddy: - image: caddy:2-alpine - ports: - - "80:80" - - "443:443" - volumes: - - ./Caddyfile:/etc/caddy/Caddyfile:ro - - caddy_data:/data - - caddy_config:/config - depends_on: - - app - restart: unless-stopped - -volumes: - postgres_data: - redis_data: - caddy_data: - caddy_config: