diff --git a/.dockerignore b/.dockerignore index 3c90104a6..f91dc6a9f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,8 @@ -node_modules -.git -.tox +.circleci +.nyc_output +.vscode .DS_Store -firefox -assets -docs -test coverage -.nyc_output +docs +firefox +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 92b3e9d3f..5570c2f22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,59 @@ +## +# Firefox Send - Mozilla +# +# License https://github.com/mozilla/send/blob/master/LICENSE +## + + +# Build project FROM node:10 AS builder -RUN addgroup --gid 10001 app && adduser --disabled-password --gecos '' --gid 10001 --home /app --uid 10001 app -COPY package*.json /app/ +RUN set -x \ + # Add user + && addgroup --gid 10001 app \ + && adduser --disabled-password \ + --gecos '' \ + --gid 10001 \ + --home /app \ + --uid 10001 \ + app +COPY --chown=app:app . /app +USER app WORKDIR /app -RUN npm install --production +RUN ls -la +RUN set -x \ + # Build + && npm ci \ + && npm run build + +# Main image FROM node:10-slim -RUN addgroup --gid 10001 app && adduser --disabled-password --gecos '' --gid 10001 --home /app --uid 10001 app +RUN set -x \ + # Add user + && addgroup --gid 10001 app \ + && adduser --disabled-password \ + --gecos '' \ + --gid 10001 \ + --home /app \ + --uid 10001 \ + app +RUN apt-get update && apt-get -y install git-core USER app WORKDIR /app -COPY --chown=app:app --from=builder /app . -COPY --chown=app:app . . +COPY --chown=app:app package*.json ./ +COPY --chown=app:app app app +COPY --chown=app:app common common +COPY --chown=app:app public/locales public/locales +COPY --chown=app:app server server +COPY --chown=app:app --from=builder /app/dist dist + +RUN ls -la +RUN npm ci --production && npm cache clean --force RUN mkdir -p /app/.config/configstore RUN ln -s dist/version.json version.json ENV PORT=1443 -EXPOSE $PORT + +EXPOSE ${PORT} CMD ["node", "server/bin/prod.js"] diff --git a/build/readme.md b/build/readme.md index 5055bfdf9..b8fc18d7a 100644 --- a/build/readme.md +++ b/build/readme.md @@ -1,8 +1,8 @@ # Custom Loaders -## Generate Asset Map +## Android Index Plugin -This loader enumerates all the files in `assets/` so that `common/assets.js` can provide mappings from the source filename to the hashed filename used on the site. +Generates the `index.html` page for the native android client ## Version Plugin diff --git a/common/assets.js b/common/assets.js index 9bbced6f0..f1a4657ec 100644 --- a/common/assets.js +++ b/common/assets.js @@ -1,4 +1,4 @@ -const genmap = require('../build/generate_asset_map'); +const genmap = require('./generate_asset_map'); const isServer = typeof genmap === 'function'; let prefix = ''; let manifest = {}; diff --git a/build/generate_asset_map.js b/common/generate_asset_map.js similarity index 100% rename from build/generate_asset_map.js rename to common/generate_asset_map.js diff --git a/common/readme.md b/common/readme.md index cbfe0ae2a..0aaad7ac3 100644 --- a/common/readme.md +++ b/common/readme.md @@ -1,3 +1,7 @@ # Common Code -This directory contains code loaded by both the frontend `app` and backend `server`. The code here can be challenging to understand at first because the contexts for the two (three counting the dev server) environments that include them are quite different, but the purpose of these modules are quite simple, to provide mappings from the source assets (`copy-16.png`) to the concrete production assets (`copy-16.db66e0bf.svg`). \ No newline at end of file +This directory contains code loaded by both the frontend `app` and backend `server`. The code here can be challenging to understand at first because the contexts for the two (three counting the dev server) environments that include them are quite different, but the purpose of these modules are quite simple, to provide mappings from the source assets (`copy-16.png`) to the concrete production assets (`copy-16.db66e0bf.svg`). + +## Generate Asset Map + +This loader enumerates all the files in `assets/` so that `common/assets.js` can provide mappings from the source filename to the hashed filename used on the site. \ No newline at end of file diff --git a/docs/docker.md b/docs/docker.md index d230558a4..975a95b2f 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,13 +1,6 @@ ## Setup -Before building the Docker image, you must build the production assets: - -```sh -npm run build -``` - -Then you can run either `docker build` or `docker-compose up`. - +Run `docker build -t send:latest .` to create an image or `docker-compose up` to run a full testable stack. *We don't recommend using docker-compose for production.* ## Environment variables: diff --git a/webpack.config.js b/webpack.config.js index 59bd140cf..de2038808 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -67,7 +67,7 @@ const serviceWorker = { }, { // loads all assets from assets/ for use by common/assets.js - test: require.resolve('./build/generate_asset_map.js'), + test: require.resolve('./common/generate_asset_map.js'), use: ['babel-loader', 'val-loader'] } ] @@ -176,7 +176,7 @@ const web = { }, { // loads all assets from assets/ for use by common/assets.js - test: require.resolve('./build/generate_asset_map.js'), + test: require.resolve('./common/generate_asset_map.js'), use: ['babel-loader', 'val-loader'] } ]