Skip to content

Commit

Permalink
Merge pull request #8 from MichelDiz/master
Browse files Browse the repository at this point in the history
add support for Docker
  • Loading branch information
panshak authored Dec 1, 2021
2 parents e2a3878 + 6d47609 commit 0041454
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,38 @@ $ npm link html-pdf
$ npm link phantomjs-prebuilt
```

## Docker

Using docker is simple. Just add the .env contextualized with the docker network.

e.g:

> goes to path "server/.env"
```
DB_URL = mongodb://mongo:27017/arch
PORT = 5000
SECRET =
SMTP_HOST =
SMTP_PORT =
SMTP_USER =
SMTP_PASS =
```
> goes to path "client/.env"
```
REACT_APP_GOOGLE_CLIENT_ID =
REACT_APP_API = http://localhost:5000
REACT_APP_URL = http://localhost
```

And run

```
docker-compose -f docker-compose.prod.yml build
And then
docker-compose -f docker-compose.prod.yml up
```

## Comment
I intend to keep adding more features to this application, so if you like it, please give it a star, that will encourage me to
Expand Down
24 changes: 24 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:14-alpine AS builder
ENV NODE_ENV production

WORKDIR /app

COPY client/package.json .
COPY client/yarn.lock .
RUN yarn install --production

COPY client .

RUN npm run build


FROM nginx:1.21.0-alpine as production
ENV NODE_ENV production

COPY --from=builder /app/build /usr/share/nginx/html

COPY ./client/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
9 changes: 9 additions & 0 deletions client/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;

location / {
root /usr/share/nginx/html/;
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html;
}
}
32 changes: 32 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.1'
services:
client:
container_name: client
image: client-prod
build:
dockerfile: ./client/Dockerfile
target: production
ports:
- '80:80'
depends_on:
- server
- mongo
links:
- server
- mongo
server:
container_name: server
image: server-prod
build:
dockerfile: ./server/Dockerfile
ports:
- '5000:5000'
depends_on:
- mongo
links:
- mongo
mongo:
image: mongo
container_name: MONGODB
ports:
- '27017'
14 changes: 14 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:14-alpine AS builder
ENV NODE_ENV production

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY server/package.json .
RUN npm install
COPY server/ .

RUN npm install && npm install nodemon --save-dev

EXPOSE 5000
CMD ["yarn", "start-prod"]

0 comments on commit 0041454

Please sign in to comment.