Build and Push Docker Images #83
Workflow file for this run
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: | |
| tags: | |
| - 'v*' # 'v'로 시작하는 태그에 대해 작업을 실행합니다. | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.TREENUT }} | |
| - name: Install Node.js and build react-frontpage | |
| run: | | |
| cd nginx/react-frontpage | |
| npm install | |
| npm run build | |
| env: | |
| NODE_VERSION: '20' # Node.js 버전은 20이상을 사용 | |
| - name: Create .env files for Docker build | |
| run: | | |
| # Root .env 파일 생성 | |
| echo "${{ secrets.DOCKER_ENV }}" > .env | |
| # MongoDB 관련 .env 파일 생성 | |
| mkdir -p mongo | |
| echo "${{ secrets.MONGO_ENV }}" > ./mongo/.env | |
| # FastAPI 관련 .env 파일 생성 | |
| mkdir -p fastapi/sources | |
| echo "${{ secrets.FASTAPI_ENV }}" > ./fastapi/sources/.env | |
| - name: Build and push Nginx image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./nginx | |
| push: true | |
| tags: | | |
| ghcr.io/treenut-kr/nginx:latest | |
| ghcr.io/treenut-kr/nginx:${{ github.ref_name }} | |
| - name: Build and push FastAPI image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./fastapi | |
| push: true | |
| tags: | | |
| ghcr.io/treenut-kr/fastapi:latest | |
| ghcr.io/treenut-kr/fastapi:${{ github.ref_name }} | |
| - name: Build and push MySQL image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./mysql | |
| push: true | |
| tags: | | |
| ghcr.io/treenut-kr/mysql:latest | |
| ghcr.io/treenut-kr/mysql:${{ github.ref_name }} | |
| - name: Build and push MongoDB image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./mongo | |
| push: true | |
| tags: | | |
| ghcr.io/treenut-kr/mongodb:latest | |
| ghcr.io/treenut-kr/mongodb:${{ github.ref_name }} |