Skip to content

Commit

Permalink
production update
Browse files Browse the repository at this point in the history
  • Loading branch information
wakidurrahman committed Dec 1, 2023
1 parent ae7b0a6 commit b189f7e
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 21 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,28 @@ jobs:
file: worker/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/multi-container-worker:${{env.LATEST_TAG}}


# https://github.com/einaregilsson/beanstalk-deploy
# Beanstalk Deploy is a GitHub action (and command line script) to deploy apps to AWS Elastic Beanstalk.
# It takes the application name, environment name, version name, region and filename as parameters, uploads the file to S3, creates a new version in Elastic Beanstalk, and then deploys that version to the environment.
# Beanstalk Deploy, Using as a GitHub Action
# Generate deployment package
# - name: Generate deployment package
# run: zip -r deploy.zip . -x '*.git*'

# # Beanstalk Deploy

# - name: Deploy apps to AWS Elastic Beanstalk
# uses: einaregilsson/beanstalk-deploy@v21
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: multi-container
# environment_name: Multi-container-env
# existing_bucket_name: elasticbeanstalk-ap-northeast-1-734549988040
# version_description: ${{github.SHA}}
# version_label: ${{ github.sha }}
# region: ap-northeast-1
# deployment_package: deploy.zip

8 changes: 4 additions & 4 deletions Dockerrun.aws.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"containerDefinitions": [
{
"name": "client",
"image": "wakidur/multi-client",
"image": "wakidur/multi-container-client",
"host": "client",
"essential": false
},
{
"name": "server",
"image": "wakidur/multi-server",
"image": "wakidur/multi-container-server",
"host": "api",
"essential": false
},
{
"name": "worker",
"image": "wakidur/multi-worker",
"image": "wakidur/multi-container-worker",
"host": "worker",
"essential": false
},
{
"name": "nginx",
"image": "wakidur/multi-nginx",
"image": "wakidur/multi-container-nginx",
"essential": true,
"memory": 128,
"portMappings": [
Expand Down
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Multi container application with docker cli, docker compose, CI + CD workflow us

- creating a pipeline that automatically deploys your code every time you push your latest changes to Github.
- Multi-Container Deployments on AWS.
- Multi-container deployments on Amazon Web Services.
- Multi-container deployments on Amazon Web Services.
- Construct a multi-container application utilizing `Node`, `React`, `Redis`, and `Postgres`, and the amazing power of containers in action.



Multi container application project structure.

```
Expand Down Expand Up @@ -37,7 +35,6 @@ Multi container application project structure.
- `tailwindcss`
- `typescript`


## Server technology and library

- `express`
Expand All @@ -48,9 +45,40 @@ Multi container application project structure.
- `nodemon`
- `parser`


## Worker technology and library

- `jest`
- `nodemon`
- `redis`

## In the project directory, you can run:

### `docker compose -f docker-compose-dev.yml up --build`

```
docker compose -f docker-compose-dev.yml up
docker compose -f docker-compose-dev.yml up --build
docker compose -f docker-compose-dev.yml down
```

Runs the app in the development mode.<br />
Open [http://localhost:3050](http://localhost:3050) to view it in the browser.

## Production

Elastic Beanstalk Instance
|-- Nginx
|-- Nginx W/Prod files
|-- Worker
|-- Express server

AWS Elastic Cache
AWS Relational Database Service

AWS VPC's and security group

- Default Virtual Private Cloud (VPC)

- - EB Instance
- - RDS (Postgres)
- - EC (Redis)
9 changes: 5 additions & 4 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# development environment specific only
version: '3.1'
services:
# https://hub.docker.com/_/postgres
Expand All @@ -14,20 +15,20 @@ services:
image: 'redis:latest'
ngins:
depends_on:
- backend
- api
- client
restart: always
build:
context: ./nginx
dockerfile: Dockerfile.dev
ports:
- '3050:80'
backend:
# Build backend service
api:
# Build api service
build:
context: ./server
dockerfile: Dockerfile.dev
# Add a new volume to the backend service for the bind mount.
# Add a new volume to the api service for the bind mount.
volumes:
# Inside the container, don't try to override this folder. Don't try to override it, don't try to redirect access to it, just leave that folder as is.
- /app/node_modules
Expand Down
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: "3"
# production environment specific only
# The production compose file will follow closely what was written in the Dockerrun.aws.json
version: "3.1"
services:
client:
image: "wakidur/multi-client"
image: "wakidur/multi-container-client"
mem_limit: 128m
hostname: client
server:
image: "wakidur/multi-server"
image: "wakidur/multi-container-server"
mem_limit: 128m
hostname: api
environment:
Expand All @@ -17,14 +19,14 @@ services:
- PGPASSWORD=$PGPASSWORD
- PGPORT=$PGPORT
worker:
image: "wakidur/multi-worker"
image: "wakidur/multi-container-worker"
mem_limit: 128m
hostname: worker
environment:
- REDIS_HOST=$REDIS_HOST
- REDIS_PORT=$REDIS_PORT
nginx:
image: "wakidur/multi-nginx"
image: "wakidur/multi-container-nginx"
mem_limit: 128m
hostname: nginx
ports:
Expand Down
6 changes: 3 additions & 3 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ upstream client {
server client:3000;
}

upstream backend {
server backend:5000;
upstream api {
server api:5000;
}

server {
Expand All @@ -24,6 +24,6 @@ server {

location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://backend;
proxy_pass http://api;
}
}

0 comments on commit b189f7e

Please sign in to comment.