refactor: next.config.mjs #127
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: Next.js CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" # Use the Node.js version compatible with Next.js 14 | |
- name: Install dependencies | |
run: npm install | |
- name: Build Next.js app | |
run: npm run build | |
- name: Login docker | |
run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
- name: Build docker image | |
run: docker build -t joaov1ct0r/nextjs_users . | |
- name: Publish image | |
run: docker push joaov1ct0r/nextjs_users | |
deploy: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Remove container | |
run: docker rm -f nextjs_users | |
- name: Remove all stopped containers | |
run: docker container prune -f | |
- name: Remove unused images | |
run: docker image prune -a -f | |
- name: Remove unused volumes | |
run: docker volume prune -f | |
- name: Pull image docker hub | |
run: docker pull joaov1ct0r/nextjs_users:latest | |
- name: Run docker container | |
run: docker run -d -p 3000:3000 --shm-size=1g -e NEXT_PUBLIC_API_URL=${{secrets.API_URL}} --name nextjs_users joaov1ct0r/nextjs_users |