Skip to content

Commit

Permalink
Tweak Docker initialization (badges#3173)
Browse files Browse the repository at this point in the history
* Tweak Docker initialization

1. Set NODE_ENV=production in Docker.
2. When NODE_ENV is production, bind to all interfaces. This seems like a
   sensible default.
3. Exclude Dockerfile from container to improve layer cacheability when
   modifying the dockerfile.

Ref badges#3165

* Rm obsolete comment
  • Loading branch information
paulmelnikow authored and calebcartwright committed Mar 7, 2019
1 parent a6d0223 commit ace2a7a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ shields.env
.git/
.gitignore
.vscode/

# Improve layer cacheability.
Dockerfile
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ RUN mkdir -p /usr/src/app
RUN mkdir /usr/src/app/private
WORKDIR /usr/src/app

ARG NODE_ENV
ENV NODE_ENV $NODE_ENV

COPY package.json package-lock.json /usr/src/app/
# Without the gh-badges package.json and CLI script in place, `npm ci` will fail.
COPY gh-badges /usr/src/app/gh-badges/
RUN npm ci

# We need dev deps to build the front end.
RUN NODE_ENV=development npm ci

COPY . /usr/src/app
RUN npm run build
RUN npm prune --production
RUN npm cache clean --force

# Do we need to list the environment variables here?
# Run the server using production configs.
ENV NODE_ENV production

CMD node server

EXPOSE 80
3 changes: 3 additions & 0 deletions config/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public:
bind:
address: '0.0.0.0'

0 comments on commit ace2a7a

Please sign in to comment.