Skip to content

Commit

Permalink
Modified compose.yml and added github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sikehish committed Jun 9, 2024
1 parent c67e8a9 commit 5d329a0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 18 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# yaml-language-server: $schema='none'

name: Deploy to AWS Elastic Beanstalk

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: docker.io
steps:
- name: Checkout code
uses: actions/checkout@v4

# # Not very useful for now, but can help in caching
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push frontend image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/langjam-frontend ./frontend
docker push ${{ secrets.DOCKERHUB_USERNAME }}/langjam-frontend
- name: Build and push backend image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/langjam-backend ./backend
docker push ${{ secrets.DOCKERHUB_USERNAME }}/langjam-backend
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: ${{ secrets.EB_APP_NAME }}
environment_name: ${{ secrets.EB_ENV_NAME }}
region: ${{ secrets.EB_REGION }}
version_label: "version-${{ github.run_number }}" #OR ${{ github.sha }}
deployment_package: docker-compose.yml
37 changes: 19 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
version: '3.8'

services:
backend:
build:
context: ./backend
image: ${DOCKER_USERNAME}/langjam-backend
ports:
- "3000:3000"
environment:
- GOOGLE_API_KEY=$GOOGLE_API_KEY
- MONGO_URI=$MONGO_URI
- MONGO_PW=$MONGO_PW
- PORT=$PORT
- JWT_KEY=$JWT_KEY
- JWT_VERIFY_KEY=$JWT_VERIFY_KEY
- JWT_ADMIN_KEY=$JWT_ADMIN_KEY
- GEMINI_KEY=$GEMINI_KEY
- REDIS_PASSWORD=$REDIS_PASSWORD
- REDIS_URI=$REDIS_URI
- OAUTH_CLIENT_ID=$OAUTH_CLIENT_ID
- OAUTH_CLIENT_SECRET=$OAUTH_CLIENT_SECRET
- CLIENT_URL=$CLIENT_URL
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
- MONGO_URI=${MONGO_URI}
- MONGO_PW=${MONGO_PW}
- PORT=${PORT}
- JWT_KEY=${JWT_KEY}
- JWT_VERIFY_KEY=${JWT_VERIFY_KEY}
- JWT_ADMIN_KEY=${JWT_ADMIN_KEY}
- GEMINI_KEY=${GEMINI_KEY}
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_URI=${REDIS_URI}
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
- CLIENT_URL=${CLIENT_URL}
volumes:
- /app/node_modules
- ./backend:/app

frontend:
build:
context: ./frontend
image: ${DOCKER_USERNAME}/langjam-frontend
ports:
- "80:80"
volumes:
- /app/node_modules
- ./frontend:/app
environment:
- VITE_REACT_APP_API_URL=$VITE_REACT_APP_API_URL
- VITE_REACT_APP_API_URL=${VITE_REACT_APP_API_URL}
depends_on:
- backend

0 comments on commit 5d329a0

Please sign in to comment.