diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..d4e0122 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea Registry + uses: docker/login-action@v3 + with: + registry: gitea.likegears.com + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + gitea.likegears.com/likegears/material_texture:${{ steps.version.outputs.VERSION }} + gitea.likegears.com/likegears/material_texture:latest diff --git a/docker-compose.build.yml b/docker-compose.build.yml new file mode 100644 index 0000000..7757316 --- /dev/null +++ b/docker-compose.build.yml @@ -0,0 +1,47 @@ +# 本地开发构建配置 +# 使用方式: docker compose -f docker-compose.build.yml up -d --build + +services: + app: + build: + context: . + dockerfile: Dockerfile + ports: + - "8081:8080" + environment: + - SERVER_PORT=8080 + - DATABASE_URL=postgres://postgres:postgres@db:5432/material_db?sslmode=disable + - API_TOKEN=${API_TOKEN:-seatons3d} + depends_on: + db: + condition: service_healthy + restart: unless-stopped + networks: + - material-network + + db: + image: postgres:15-alpine + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=material_db + volumes: + - postgres_data:/var/lib/postgresql/data + - ./migrations:/docker-entrypoint-initdb.d:ro + ports: + - "5433:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + restart: unless-stopped + networks: + - material-network + +volumes: + postgres_data: + +networks: + material-network: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index b2fe539..875d96b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ services: app: - build: - context: . - dockerfile: Dockerfile + image: gitea.likegears.com/likegears/material_texture:latest ports: - "8081:8080" environment: