Skip to content

Commit 7d450df

Browse files
author
Greg Brown
committed
Optimise Docker image for production use
1 parent dc0523e commit 7d450df

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ ENV PATH /home/node/app/node_modules/.bin:$PATH
1111

1212
# install and cache app dependencies
1313
COPY package.json ./package.json
14-
RUN npm install --silent
15-
RUN npm install [email protected] -g --silent
14+
RUN npm install [email protected] -g --silent \
15+
&& npm install --silent \
16+
&& npm cache clean --force
17+
18+
# Copy project source files
19+
COPY . .
1620

1721
# start app
1822
CMD ["npm", "start"]

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,31 @@ The `jenkins` directory contains an example of the `Jenkinsfile` (i.e. Pipeline)
1212
you'll be creating yourself during the tutorial and the `scripts` subdirectory
1313
contains shell scripts with commands that are executed when Jenkins processes
1414
the "Test" and "Deliver" stages of your Pipeline.
15+
16+
## Using the Registry
17+
18+
Manually:
19+
20+
```bash
21+
docker image build -t localhost:5000/simple-react-app .
22+
```
23+
24+
Push:
25+
26+
```bash
27+
docker push localhost:5000/simple-react-app
28+
```
29+
30+
Remove local image:
31+
32+
```bash
33+
docker image rm localhost:5000/simple-react-app
34+
```
35+
36+
Pull:
37+
38+
```bash
39+
docker pull localhost:5000/simple-react-app
40+
```
41+
42+
## TODO - Set up Jenkins to build and push images into registry

docker-compose.prod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ version: "3.1"
33
services:
44
client:
55
ports:
6-
- '3000:3000'
6+
- '3050:3000'
77
environment:
88
- NODE_ENV=production

0 commit comments

Comments
 (0)