Simplify frontend Dockerfile to create a minimal static site #11
This file contains 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: CI/CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8.15.4 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: Setup pnpm cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run frontend tests | |
run: pnpm --filter @ogdrip/frontend test | |
test-backend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Install Chromium | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y chromium-browser | |
- name: Run backend tests | |
run: | | |
cd backend | |
go test -v ./... | |
build: | |
needs: [test-frontend, test-backend] | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push frontend | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./frontend | |
file: ./frontend/Dockerfile.production | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ogdrip-frontend:latest | |
- name: Build and push backend | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile.production | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ogdrip-backend:latest | |
deploy: | |
needs: build | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to production | |
run: | | |
echo "Deploying to production server" | |
# Add your deployment commands here | |
# For example, SSH into your server and pull the latest Docker images | |
# ssh user@your-server "docker-compose -f docker-compose.production.yml pull && docker-compose -f docker-compose.production.yml up -d" |