feat: Add Dockerfile and GitHub Actions workflow for ResourceHub depl… #1
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: Deploy ResourceHub | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/resourcehub:latest | |
| # No build-args for secrets; secrets will be injected at runtime | |
| # Add deployment steps | |
| - name: Deploy container | |
| env: | |
| USER: ${{ secrets.USER }} | |
| PASSWORD: ${{ secrets.PASSWORD }} | |
| HOST: ${{ secrets.HOST }} | |
| PORT: ${{ secrets.PORT }} | |
| DATABASE: ${{ secrets.DATABASE }} | |
| SMTP_HOST: ${{ secrets.SMTP_HOST }} | |
| SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
| SMTP_USER: ${{ secrets.SMTP_USER }} | |
| PDFSHIFT_API_KEY: ${{ secrets.PDFSHIFT_API_KEY }} | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| run: | | |
| docker run -d \ | |
| -e USER="$USER" \ | |
| -e PASSWORD="$PASSWORD" \ | |
| -e HOST="$HOST" \ | |
| -e PORT="$PORT" \ | |
| -e DATABASE="$DATABASE" \ | |
| -e SMTP_HOST="$SMTP_HOST" \ | |
| -e SMTP_PASSWORD="$SMTP_PASSWORD" \ | |
| -e SMTP_USER="$SMTP_USER" \ | |
| -e PDFSHIFT_API_KEY="$PDFSHIFT_API_KEY" \ | |
| -p 80:80 -p 9090-9094:9090-9094 \ | |
| "$DOCKERHUB_USERNAME/resourcehub:latest" |