Skip to content
Open
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
5 changes: 5 additions & 0 deletions .ebextensions/01.db.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
option_settings:
aws:elasticbeanstalk:application:environment:
NODE_ENV: "develop"
DATABASE_URL: "postgresql://postgres:HqYEvjt6WhIyaDuZxjzm@scale-diary-db-develop.cvs4eam02tzq.ap-northeast-2.rds.amazonaws.com:5432/scalediary"
REDIS_URL: "scale-diary-cache-develop.9hs1lu.ng.0001.apn2.cache.amazonaws.com:6379"
67 changes: 49 additions & 18 deletions .github/workflows/develop.build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
name: Deploy Devleopment
name: Deploy Development to Elastic Beanstalk

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}

on:
push:
pull_request:
branches:
- develop

jobs:
build:
# if: "!contains(github.event.head_commit.message, 'NOT DEPLOY')"
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

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

# - name: Generate deployment package
# run: zip -r deploy.zip . -x '*.git*' 'node_modules/*'

# - name: Deploy to EB
# uses: einaregilsson/beanstalk-deploy@v22
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: scale-diary-server-develop
# environment_name: scale-diary-server-develop-env
# version_label: develop-${{ github.sha }}
# region: ap-northeast-2
# deployment_package: deploy.zip
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and Push Docker image
run: |
docker buildx build --platform linux/amd64 -t $DOCKER_USERNAME/muda .
docker push $DOCKER_USERNAME/muda

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Deploy to Elastic Beanstalk
run: |
eb init -p docker muda --region $AWS_REGION
eb use develop
eb deploy --staged

# - name: Generate deployment package
# run: zip -r deploy.zip . -x '*.git*' 'node_modules/*'

# - name: Deploy to EB
# uses: einaregilsson/beanstalk-deploy@v22
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: scale-diary-server-develop
# environment_name: scale-diary-server-develop-env
# version_label: develop-${{ github.sha }}
# region: ap-northeast-2
# deployment_package: deploy.zip
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Stage 1: Build the application
FROM node:20-alpine AS builder
WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install

# Copy the rest of the application code and build it
COPY . .
RUN npm run build

# Generate Prisma client
RUN npm exec prisma generate

# Stage 2: Create production image
FROM node:20-alpine AS runner
WORKDIR /app

# Copy built application from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
COPY ./.env ./

EXPOSE 5000
CMD ["npm", "run", "start:prod"]