diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..9ecdf79 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + outputs: + image: ${{ steps.meta.outputs.tags }} + steps: + - uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/eq-muster + tags: | + type=sha,prefix=sha- + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + + deploy: + needs: build-and-push + runs-on: ubuntu-latest + steps: + - name: Deploy to VPS + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.VPS_HOST }} + username: root + key: ${{ secrets.VPS_SSH_KEY }} + script: | + set -e + cd /srv/eq-muster + docker compose pull + docker compose up -d + docker image prune -f diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc6250a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.14-slim AS builder + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv + +WORKDIR /app + +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-dev --no-editable + +COPY src/ ./src/ +RUN uv sync --frozen --no-dev + + +FROM python:3.14-slim + +WORKDIR /app + +COPY --from=builder /app/.venv /app/.venv +COPY --from=builder /app/src /app/src + +ENV PATH="/app/.venv/bin:$PATH" + +CMD ["eq-muster"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1667e61 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +services: + eq-muster: + image: heki0323/eq-muster:latest + restart: unless-stopped + env_file: .env