diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cd643c1..90806ce 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,4 +20,8 @@ jobs: key: ${{ secrets.DEV_TEST }} port: 22 script: | - ls -al \ No newline at end of file + cd /home/ec2-user/app + git pull origin main + docker compose down + docker compose up -d --build + docker ps \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..83a1edb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: test with create .env test + +on: [pull_request] + +jobs: + build: + name: React build & test + runs-on: ubuntu-latest + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: testuser + POSTGRES_PASSWORD: testpass + POSTGRES_DB: testdb + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U testuser" + --health-interval 5s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create .env + run: | + echo "Port=3000" >> .env + echo "SESSION_SECRET=your_session_secret" >> .env + echo "JWT_ACCESS_TOKEN_SECRET=your_jwt_access_token_secret" >> .env + echo "JWT_REFRESH_TOKEN_SECRET=your_jwt_refresh_token_secret" >> .env + # 테스트용 로컬 Postgres + echo "DATABASE_URL=postgres://testuser:testpass@localhost:5432/testdb" >> .env + echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env + echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env + echo "AWS_S3_BUCKET=${{ secrets.AWS_S3_BUCKET }}" >> .env + + - name: Install dependencies + run: npm install + + - name: Prisma Generate + run: npx prisma generate + + - name: Prisma Migrate Dev + run: npx prisma migrate deploy + + - name: Run tests + run: npm test -- --runInBand diff --git a/.gitignore b/.gitignore index 108bb11..c7ba734 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ node_modules /generated/prisma -coverage - dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf50bb8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# 1. Node.js +FROM node:20.13.1 + +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +# Prisma generate +RUN npx prisma generate + +COPY . . + +RUN mkdir -p /app/uploads + +# TypeScript 빌드 +RUN npx tsc + +EXPOSE 3000 +CMD ["npm", "start"] diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html index a9fe99f..5b6e6af 100644 --- a/coverage/lcov-report/index.html +++ b/coverage/lcov-report/index.html @@ -23,30 +23,30 @@