Skip to content

Commit

Permalink
Merge pull request #131 from ITZipProject/main
Browse files Browse the repository at this point in the history
fix: action 수정
  • Loading branch information
Jukrap 2호기 authored Nov 20, 2024
2 parents 35bafa8 + 05ea6f5 commit 50e13da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ on:
jobs:
build:
runs-on: ubuntu-latest

env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}

steps:
- uses: actions/checkout@v3

- name: Login Dockerhub
env:
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
Expand All @@ -19,9 +23,11 @@ jobs:
- name: make .env
run: |
touch .env
echo "${{ secrets.SECRET_ENV}}" > .env
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> .env
echo "${{ secrets.SECRET_ENV}}" >> .env
- name: Builder the Docker image
run: docker build -t ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 .
run: docker build --build-arg NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} -t ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 .

- name: taging
run: docker tag ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2:latest
Expand All @@ -37,7 +43,8 @@ jobs:
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" > /home/ubuntu/itzip/.env
docker-compose -f /home/ubuntu/itzip/docker-compose.yml down
docker-compose -f /home/ubuntu/itzip/docker-compose.yml pull
docker-compose -f /home/ubuntu/itzip/docker-compose.yml up -d
docker system prune -a -f
docker system prune -a -f
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build

# 실행 단계
Expand All @@ -12,6 +14,9 @@ WORKDIR /app

ENV NODE_ENV production

ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
ports:
- "3000:3000"

Expand Down

0 comments on commit 50e13da

Please sign in to comment.