feat: add SSL certificate generation step for proxy build in Docker w… #404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Images | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_OWNER: ${{ github.repository_owner }} | |
| jobs: | |
| build-and-push: | |
| name: Build & Push Docker Images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set lowercase repo and owner | |
| id: vars | |
| run: | | |
| echo "owner_lower=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| echo "repo_lower=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Copy and patch .env | |
| run: | | |
| cp .env.example .env | |
| - name: Generate SSL certificates for proxy build | |
| run: | | |
| mkdir -p infra/proxy/ssl | |
| openssl req -x509 -nodes -days 1 -newkey rsa:2048 \ | |
| -keyout infra/proxy/ssl/_wildcard.poveroh.local+1-key.pem \ | |
| -out infra/proxy/ssl/_wildcard.poveroh.local+1.pem \ | |
| -subj "/CN=*.poveroh.local" 2>/dev/null | |
| - name: Build Docker images using local compose file | |
| run: docker compose -f docker/docker-compose.local.yml --env-file .env build | |
| - name: Tag and push images | |
| run: | | |
| for service in db api app redis proxy; do | |
| docker tag ${{ steps.vars.outputs.repo_lower }}-$service ghcr.io/${{ steps.vars.outputs.owner_lower }}/${{ steps.vars.outputs.repo_lower }}-$service:latest | |
| docker push ghcr.io/${{ steps.vars.outputs.owner_lower }}/${{ steps.vars.outputs.repo_lower }}-$service:latest | |
| done |