Skip to content

Commit 7bd6926

Browse files
committed
dockerfile improvement
1 parent 6d24e53 commit 7bd6926

File tree

5 files changed

+57
-84
lines changed

5 files changed

+57
-84
lines changed

.circleci/config.yml

-78
This file was deleted.

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ Copy the file named `.env.example` into a new file named simply, `.env`.
8686

8787
Make sure the `FRONT_END_DOMAIN` setting in this file specifies the correct domain and port where the React front-end app is running.
8888

89+
e.g.
90+
8991
```js
90-
FRONT_END_DOMAIN=http://localhost:3001
92+
FRONT_END_DOMAIN=http://localhost:4000
9193
```
9294

9395
### Install dependencies
@@ -128,7 +130,7 @@ The containerized back-end app should now be running as a background daemon on `
128130

129131
### Front-end
130132

131-
Open the front-end (`http://localhost:4000`) in your favorite web browser (this should have popped open automatically, unless running the containerized version of the app). Open the browser's `Developer Tools`:
133+
Open the front-end (`http://localhost:4000` or whichever port React's dev server is runnong on) in your favorite web browser (this should have popped open automatically, unless running the containerized version of the app). Open the browser's `Developer Tools`:
132134

133135
- use the `Console` tab to see any debugging output from the Javascript code running in the browser.
134136
- use the `Network` tab to see details of all HTTP requests and responses to/from the back-end server. In particular, look at the cookie and authorization-related HTTP headers.

back-end/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
FROM node:16
33

44
# create an app directory within the image... if doing this, just make sure your other Dockerfile commands reference this directory
5-
# WORKDIR /app
5+
WORKDIR /app
66

77
# install dependencies into the image - doing this first will speed up subsequent builds, as Docker will cache this step
8-
COPY package*.json ./
8+
COPY package*.json .
99
RUN npm install
1010

1111
# copy the remaining app source code into the default directory within the image

docker-compose.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: '3.8'
2+
3+
services:
4+
mongo:
5+
image: mongo:latest
6+
container_name: ds-mongo
7+
ports:
8+
- '27017:27017'
9+
# volumes:
10+
# - mongo-data:/data/db
11+
environment:
12+
- MONGO_INITDB_ROOT_USERNAME=admin
13+
- MONGO_INITDB_ROOT_PASSWORD=secret
14+
15+
backend:
16+
image: node:latest
17+
container_name: ds-backend
18+
working_dir: /app
19+
# volumes:
20+
# - /data/backend:/app
21+
ports:
22+
- '3000:3000'
23+
environment:
24+
- FRONT_END_DOMAIN=http://localhost:4000
25+
- JWT_SECRET=knowledge.kitchen
26+
- JWT_EXP_DAYS=60
27+
- MONGODB_URI=mongodb://admin:secret@localhost:27017/data-storage-app?authSource=admin
28+
depends_on:
29+
- mongo
30+
command: sh -c "npm install && npm start"
31+
frontend:
32+
image: node:latest
33+
container_name: ds-frontend
34+
working_dir: /app
35+
# volumes:
36+
# - /data/front-end:/app
37+
environment:
38+
- PORT=4000 # the port at which the react app will run
39+
- REACT_APP_BACKEND=http://localhost:3000
40+
ports:
41+
- '4000:4000'
42+
depends_on:
43+
- backend
44+
command: sh -c "npm install && npm start"
45+
# volumes:
46+
# mongo-data:

front-end/Dockerfile

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
FROM node:16
33

44
# create an app directory within the image... if doing this, just make sure your other Dockerfile commands reference this directory
5-
# WORKDIR /app
5+
WORKDIR /app
66

77
# install dependencies into the image - doing this first will speed up subsequent builds, as Docker will cache this step
8-
COPY package*.json ./
8+
COPY package*.json .
99
RUN npm install
1010

1111
# copy the remaining app source code into the default directory within the image
1212
COPY . .
1313

14+
# install dependencies into the image
15+
RUN npm install
16+
1417
# expose port 4000 to make it available to the docker daemon
1518
EXPOSE 4000
1619

0 commit comments

Comments
 (0)