Skip to content

Commit 770d96b

Browse files
committed
Update Dockerfile, docker-compose.yml and add .dockerignore so builds are now self-contained, update README.md
1 parent 6ffee4d commit 770d96b

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.git/
4+
.gitignore
5+
README.md

Dockerfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
FROM node:6
1+
# Use the slim version of the latest Node LTS which includes Yarn
2+
FROM node:6.10.2-slim
23

3-
RUN apt-get update
4-
RUN apt-get install apt-transport-https
4+
# Docker images have no default editor so we'll use vim
5+
RUN apt-get update && apt-get install -y \
6+
vim
57

6-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
7-
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
8-
9-
RUN apt-get update
10-
RUN apt-get install yarn
8+
# Create an app directory for our app to exist in the docker container
9+
RUN mkdir -p app
1110

11+
# Establish a directory where later commands will be run relative to in the container
1212
WORKDIR /app
1313

14+
# Copy package.json & yarn.lock into our app directory in the container
15+
COPY package.json \
16+
yarn.lock \
17+
# Destination folder
18+
/app/
19+
20+
# Install dependencies in the container
21+
RUN yarn install
22+
23+
# Copy all the rest of our files into the app directory in the container
24+
COPY . /app
25+
26+
# Expose port for webpack
1427
EXPOSE 8080

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ git push origin master
3333

3434
## Commands
3535

36-
Run your tests with:
37-
```
38-
yarn test
39-
```
4036
Run the server with:
4137
```
4238
yarn start
4339
```
40+
41+
Run your tests with:
42+
```
43+
yarn test
44+
```
45+
4446
Run a build with:
4547
```
4648
yarn build
@@ -50,7 +52,7 @@ yarn build
5052

5153
Build and start the server:
5254
```
53-
docker-compose up
55+
docker-compose up --build
5456
```
5557

5658
Run your tests with:
@@ -62,3 +64,8 @@ Run a build with:
6264
```
6365
docker-compose exec web yarn build
6466
```
67+
68+
If your terminal closes run:
69+
```
70+
docker-compose logs --follow
71+
```

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
web:
55
tty: true
66
build: .
7-
command: bash -c "yarn && yarn start"
7+
command: 'yarn start'
88
ports:
9-
- '8080:8080'
9+
- "8080:8080"
1010
volumes:
11-
- .:/app:rw
11+
- .:/app

0 commit comments

Comments
 (0)