Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: Test and Build Docker Image to ECR
name: Build and Deploy to EC2 with Docker Compose

on:
pull_request:
push:
branches:
- main
- chore/deploy-to-ec2

jobs:
build-and-test:
build-and-push:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18]
# strategy:
# matrix:
# node-version: [18]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# - name: Set up Node ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}

- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
# - name: Cache node_modules
# uses: actions/cache@v3
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: ${{ runner.os }}-node-

- name: Install dependencies
run: npm ci
# - name: Install dependencies
# run: npm ci

- name: Build
run: npm run build
# - name: Build
# run: npm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
Expand Down
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Dockerfile for factoreal-FE

FROM node:18
# Stage 1: Build the application
FROM node:18-alpine AS builder

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm install
RUN npm ci

COPY . .

ENV NODE_ENV=development
ENV HOST=0.0.0.0
RUN npm run build

EXPOSE 5173
# Stage 2: Serve application with Nginx
FROM nginx:stable-alpine

CMD ["npm", "run", "dev", "--", "--host" ]
COPY --from=builder /app/dist /usr/share/nginx/html

COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
26 changes: 26 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
listen 80;
server_name 43.200.39.139;

# 프론트엔드 정적 파일 서비스
location / {
root /usr/share/nginx/html;
index index.html index.html;
try_files $uri $uri/ /index.html;
}

# 백엔드 API 프록시 설정
# /api/ 로 시작하는 모든 요청을 백엔드 서버로 전달
location /api {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# WebSocket을 사용한다면 다음 설정 추가
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
}
}
Loading