Skip to content

Commit

Permalink
Enable prod deployment to Beanstalk
Browse files Browse the repository at this point in the history
* separate compose file for development and production
  • Loading branch information
santosh committed Sep 9, 2021
1 parent b5d1860 commit 8d14a48
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 34 deletions.
26 changes: 12 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sudo: required
language: generic
services:
- docker

Expand All @@ -10,17 +11,14 @@ script:
# Run tests for client
- docker run -e CI=true $DOCKER_ID/complex-client:test npm test

after_success:
# Build production version of images
- docker build -t $DOCKER_ID/complex-client ./client
- docker build -t $DOCKER_ID/complex-nginx ./nginx
- docker build -t $DOCKER_ID/complex-server ./server
- docker build -t $DOCKER_ID/complex-worker ./worker

# Login to the Docker CLI
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
# Push production version of images to Docker Hub
- docker push $DOCKER_ID/complex-client
- docker push $DOCKER_ID/complex-nginx
- docker push $DOCKER_ID/complex-server
- docker push $DOCKER_ID/complex-worker
deploy:
provider: elasticbeanstalk
region: ap-south-1
app: "docker-complex"
env: "Dockercomplex-env"
bucket_name: "elasticbeanstalk-ap-south-1-887635673391"
bucket_path: "docker-complex"
on:
branch: master
access_key_id: $AWS_ACCESS_KEY
secret_access_key: $AWS_SECRET_KEY
62 changes: 62 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '3'

services:
postgres:
image: 'postgres:latest'
environment:
- POSTGRES_PASSWORD=postgres_password

redis:
image: 'redis:latest'

api:
build:
context: ./server
dockerfile: Dockerfile.dev
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
- PGUSER=postgres
- PGHOST=postgres
- PGDATABASE=postgres
- PGPASSWORD=postgres_password
- PGPORT=5432
volumes:
- /app/node_modules
- ./server:/app
depends_on:
- redis
- postgres

client:
stdin_open: true
build:
dockerfile: Dockerfile.dev
context: ./client
volumes:
- /home/node/app/node_modules
- ./client:/home/node/app

worker:
build:
dockerfile: Dockerfile.dev
context: ./worker
volumes:
- /app/node_modules
- ./worker:/app
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
- redis

nginx:
restart: always
build:
context: ./nginx
dockerfile: Dockerfile.dev
ports:
- '3050:80'
depends_on:
- api
- client
31 changes: 11 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ services:
image: 'redis:latest'

api:
build:
context: ./server
dockerfile: Dockerfile.dev
image: sntshk/complex-server
mem_limit: 128m
hostname: api
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
Expand All @@ -29,34 +29,25 @@ services:
- postgres

client:
stdin_open: true
build:
dockerfile: Dockerfile.dev
context: ./client
volumes:
- /home/node/app/node_modules
- ./client:/home/node/app
image: sntshk/complex-client
mem_limit: 128m
hostname: client

worker:
build:
dockerfile: Dockerfile.dev
context: ./worker
volumes:
- /app/node_modules
- ./worker:/app
image: sntshk/complex-worker
mem_limit: 128m
hostname: worker
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
- redis

nginx:
image: sntshk/complex-nginx
restart: always
build:
context: ./nginx
dockerfile: Dockerfile.dev
ports:
- '3050:80'
- '80:80'
depends_on:
- api
- client

0 comments on commit 8d14a48

Please sign in to comment.