Skip to content

Commit

Permalink
Update Dockerfile so it builds and runs (github#17469)
Browse files Browse the repository at this point in the history
* Update Dockerfile so it at least builds

* And get it running again!

* Update Dockerfile

* Create build-docker-image.yml

* Update build-docker-image.yml

* Update Dockerfile

* Update Dockerfile

* Delete build-docker-image.yml
  • Loading branch information
heiskr authored Feb 1, 2021
1 parent 83b9158 commit c640f6d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Make sure the Docker container still builds

name: Build Docker image

on:
push:
branches:
- main
pull_request:
branches-ignore:
- translations

env:
CI: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Build the container
run: docker build .
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
# A temporary image that installs production-only dependencies

FROM node:14-alpine as installation
RUN apk add --no-cache python make g++
ENV NODE_ENV production
WORKDIR /usr/src/docs
COPY package*.json ./

# Install the project's dependencies
RUN npm ci
RUN npm ci --production

# --------------------------------------------------------------------------------
# BUNDLE IMAGE
# A temporary image that installs dependencies and builds the production-ready front-end bundles.

FROM node:14-alpine as bundles
RUN apk add --no-cache python make g++
ENV NODE_ENV production
WORKDIR /usr/src/docs
# Install the files used to create the bundles
COPY package*.json ./
Expand All @@ -27,7 +30,8 @@ COPY stylesheets ./stylesheets
COPY lib ./lib
COPY webpack.config.js ./webpack.config.js
# Install the project's dependencies and build the bundles
RUN npm ci && npm run build
RUN npm ci --production
RUN npm run build

# --------------------------------------------------------------------------------
# MAIN IMAGE
Expand All @@ -52,16 +56,23 @@ COPY --chown=node:node --from=bundles /usr/src/docs/dist /usr/src/docs/dist
# We should always be running in production mode
ENV NODE_ENV production

# Use Lunr instead of Algolia
ENV USE_LUNR true

# Copy only what's needed to run the server
COPY --chown=node:node assets ./assets
COPY --chown=node:node content ./content
COPY --chown=node:node data ./data
COPY --chown=node:node includes ./includes
COPY --chown=node:node layouts ./layouts
COPY --chown=node:node lib ./lib
COPY --chown=node:node middleware ./middleware
COPY --chown=node:node translations ./translations
COPY --chown=node:node server.js ./server.js
COPY --chown=node:node package*.json ./
COPY --chown=node:node feature-flags.json ./

EXPOSE 80
EXPOSE 443
EXPOSE 4000
CMD ["node", "server.js"]

0 comments on commit c640f6d

Please sign in to comment.