From 184e0095524edf6c6cfd5c7171228c5d6309829a Mon Sep 17 00:00:00 2001 From: Lee Allen Date: Sat, 22 Apr 2017 19:38:09 -0400 Subject: [PATCH] Update Dockerfile, docker-compose.yml and add .dockerignore so builds are now self-contained, update README.md --- .dockerignore | 6 ++++++ Dockerfile | 29 +++++++++++++++++++++-------- README.md | 17 ++++++++++++----- docker-compose.yml | 6 +++--- 4 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..40a0b47 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules/ +dist/ +.git/ +.gitignore +README.md +*.log diff --git a/Dockerfile b/Dockerfile index d437207..9abb073 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 1b84c1a..f2af10a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -50,7 +52,7 @@ yarn build Build and start the server: ``` -docker-compose up +docker-compose up --build ``` Run your tests with: @@ -62,3 +64,8 @@ Run a build with: ``` docker-compose exec web yarn build ``` + +If your terminal closes run: +``` +docker-compose logs --follow +``` diff --git a/docker-compose.yml b/docker-compose.yml index d03c4ca..67b0f88 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,8 @@ services: web: tty: true build: . - command: bash -c "yarn && yarn start" + command: 'yarn start' ports: - - '8080:8080' + - "8080:8080" volumes: - - .:/app:rw + - .:/app