Skip to content

Commit

Permalink
Added Prod features with AWS config in complex project
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchit Bhatnagar committed Sep 19, 2020
1 parent 98eb6ca commit 38d5ca2
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 7 deletions.
34 changes: 34 additions & 0 deletions complex/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
sudo: required
services:
- docker

before_install:
- docker build -t sanchitb23/react-test -f ./client/Dockerfile.dev ./client

script:
- docker run -r CI=true sanchitb23/react-test npm test

after_success:
- docker build -t sanchitb23/complex-client ./client
- docker build -t sanchitb23/complex-nginx ./nginx
- docker build -t sanchitb23/complex-server ./server
- docker build -t sanchitb23/complex-worker ./worker
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
- docker push sanchitb23/complex-client
- docker push sanchitb23/complex-nginx
- docker push sanchitb23/complex-server
- docker push sanchitb23/complex-worker

deploy:
edge: true
provider: elasticbeanstalk
region: us-west-1
app: mutli-docker
env: MultiDocker-env
bucket: s3bucketname
bucket_path: docker-multi
on:
branch: master
access_key_id: $AWS_ACCESS_KEY
secret_access_key: $AWS_SECRET_KEY

43 changes: 43 additions & 0 deletions complex/Dockerrun.aws.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "client",
"image": "sanchitb23/complex-client",
"hostname": "client",
"memory": 128,
"essential": false
},
{
"name": "server",
"image": "sanchitb23/complex-server",
"hostname": "api",
"memory": 128,
"essential": false
},
{
"name": "worker",
"image": "sanchitb23/complex-worker",
"hostname": "worker",
"memory": 128,
"essential": false
},
{
"name": "nginx",
"image": "sanchitb23/complex-nginx",
"hostname": "nginx",
"essential": true,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80
}
],
"memory": 128,
"links": [
"client",
"server"
]
}
]
}
11 changes: 11 additions & 0 deletions complex/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:alpine as builder
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx
EXPOSE 3000
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/build /usr/share/nginx/html
9 changes: 9 additions & 0 deletions complex/client/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 3000;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
8 changes: 1 addition & 7 deletions complex/client/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
test('renders learn react link', () => {});
3 changes: 3 additions & 0 deletions complex/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx

COPY ./default.conf /etc/nginx/conf.d/default.conf
11 changes: 11 additions & 0 deletions complex/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:alpine

WORKDIR '/app'

COPY ./package.json .

RUN npm install

COPY . .

CMD ["npm","run","start"]
11 changes: 11 additions & 0 deletions complex/worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:alpine

WORKDIR '/app'

COPY ./package.json .

RUN npm install

COPY . .

CMD ["npm","run","start"]

0 comments on commit 38d5ca2

Please sign in to comment.