Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to containerize the app for Docker #47

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
.git/
.gitignore
README.md
*.log
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
FROM node:6
# Use the slim version of the latest Node LTS which includes Yarn
FROM node:6.10.2-slim

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

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update
RUN apt-get install yarn
# Create an app directory for our app to exist in the docker container
RUN mkdir -p app

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

# Copy package.json & yarn.lock into our app directory in the container
COPY package.json \
yarn.lock \
# Destination folder
/app/

# Install dependencies in the container
RUN yarn install

# Copy all the rest of our files into the app directory in the container
COPY . /app

# Expose port for webpack
EXPOSE 8080
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ git push origin master

## Commands

Run your tests with:
```
yarn test
```
Run the server with:
```
yarn start
```

Run your tests with:
```
yarn test
```

Run a build with:
```
yarn build
Expand All @@ -50,7 +52,7 @@ yarn build

Build and start the server:
```
docker-compose up
docker-compose up --build
```

Run your tests with:
Expand All @@ -62,3 +64,8 @@ Run a build with:
```
docker-compose exec web yarn build
```

If your terminal closes run:
```
docker-compose logs --follow
```
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ services:
web:
tty: true
build: .
command: bash -c "yarn && yarn start"
command: 'yarn start'
ports:
- '8080:8080'
- "8080:8080"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this to double quotes and above to single? Will one or the other not work?

Copy link
Contributor Author

@leeallen337 leeallen337 Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe they both work. I came across this SO question/answer when browsing between the difference. However, I ultimately decided on double quotes because in Docker's own documentation they use double. See here

volumes:
- .:/app:rw
- .:/app