Add instructions to run app as Docker container (#68)

This commit is contained in:
shm
2017-11-16 13:37:19 +01:00
committed by GitHub
parent 9e07bf63ae
commit ffc2df6a41
3 changed files with 50 additions and 2 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
node_modules
npm-debug.log

15
Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:9
WORKDIR /app
RUN npm install -g contentful-cli
COPY package.json .
RUN npm install
COPY . .
USER node
EXPOSE 3000
CMD ["npm", "run", "start:dev"]

View File

@@ -97,3 +97,34 @@ You can also deploy this app to Heroku:
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
## Use Docker
You can also run this app as a Docker container:
Step 1: Clone the repo
```bash
git clone https://github.com/contentful/the-example-app.nodejs.git
```
Step 2: Build the Docker image
```bash
docker build -t the-example-app.nodejs .
```
Step 3: Run the Docker container locally:
```bash
docker run -p 3000:3000 -d the-example-app.nodejs
```
If you created your own Contentful space, you can use it by overriding the following environment variables:
```bash
docker run -p 3000:3000 \
-e CONTENTFUL_SPACE_ID=<SPACE_ID> \
-e CONTENTFUL_DELIVERY_TOKEN=<DELIVERY_ACCESS_TOKEN> \
-e CONTENTFUL_PREVIEW_TOKEN=<PREVIEW_ACCESS_TOKEN> \
-d the-example-app.nodejs
```