Skip to content

Commit 90f6a07

Browse files
thenetsdannycoates
authored andcommitted
refactored Dockerfile
1 parent 8f4a53d commit 90f6a07

File tree

8 files changed

+64
-29
lines changed

8 files changed

+64
-29
lines changed

.dockerignore

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
node_modules
2-
.git
3-
.tox
1+
.circleci
2+
.nyc_output
3+
.vscode
44
.DS_Store
5-
firefox
6-
assets
7-
docs
8-
test
95
coverage
10-
.nyc_output
6+
docs
7+
firefox
8+
node_modules

Dockerfile

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,59 @@
1+
##
2+
# Firefox Send - Mozilla
3+
#
4+
# License https://github.com/mozilla/send/blob/master/LICENSE
5+
##
6+
7+
8+
# Build project
19
FROM node:10 AS builder
2-
RUN addgroup --gid 10001 app && adduser --disabled-password --gecos '' --gid 10001 --home /app --uid 10001 app
3-
COPY package*.json /app/
10+
RUN set -x \
11+
# Add user
12+
&& addgroup --gid 10001 app \
13+
&& adduser --disabled-password \
14+
--gecos '' \
15+
--gid 10001 \
16+
--home /app \
17+
--uid 10001 \
18+
app
19+
COPY --chown=app:app . /app
20+
USER app
421
WORKDIR /app
5-
RUN npm install --production
22+
RUN ls -la
23+
RUN set -x \
24+
# Build
25+
&& npm ci \
26+
&& npm run build
627

28+
29+
# Main image
730
FROM node:10-slim
8-
RUN addgroup --gid 10001 app && adduser --disabled-password --gecos '' --gid 10001 --home /app --uid 10001 app
31+
RUN set -x \
32+
# Add user
33+
&& addgroup --gid 10001 app \
34+
&& adduser --disabled-password \
35+
--gecos '' \
36+
--gid 10001 \
37+
--home /app \
38+
--uid 10001 \
39+
app
40+
RUN apt-get update && apt-get -y install git-core
941
USER app
1042
WORKDIR /app
11-
COPY --chown=app:app --from=builder /app .
12-
COPY --chown=app:app . .
43+
COPY --chown=app:app package*.json ./
44+
COPY --chown=app:app app app
45+
COPY --chown=app:app common common
46+
COPY --chown=app:app public/locales public/locales
47+
COPY --chown=app:app server server
48+
COPY --chown=app:app --from=builder /app/dist dist
49+
50+
RUN ls -la
51+
RUN npm ci --production && npm cache clean --force
1352
RUN mkdir -p /app/.config/configstore
1453
RUN ln -s dist/version.json version.json
1554

1655
ENV PORT=1443
17-
EXPOSE $PORT
56+
57+
EXPOSE ${PORT}
1858

1959
CMD ["node", "server/bin/prod.js"]

build/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Custom Loaders
22

3-
## Generate Asset Map
3+
## Android Index Plugin
44

5-
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.
5+
Generates the `index.html` page for the native android client
66

77
## Version Plugin
88

common/assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const genmap = require('../build/generate_asset_map');
1+
const genmap = require('./generate_asset_map');
22
const isServer = typeof genmap === 'function';
33
let prefix = '';
44
let manifest = {};

common/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Common Code
22

3-
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`).
3+
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`).
4+
5+
## Generate Asset Map
6+
7+
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.

docs/docker.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
## Setup
22

3-
Before building the Docker image, you must build the production assets:
4-
5-
```sh
6-
npm run build
7-
```
8-
9-
Then you can run either `docker build` or `docker-compose up`.
10-
3+
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.*
114

125
## Environment variables:
136

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const serviceWorker = {
6767
},
6868
{
6969
// loads all assets from assets/ for use by common/assets.js
70-
test: require.resolve('./build/generate_asset_map.js'),
70+
test: require.resolve('./common/generate_asset_map.js'),
7171
use: ['babel-loader', 'val-loader']
7272
}
7373
]
@@ -176,7 +176,7 @@ const web = {
176176
},
177177
{
178178
// loads all assets from assets/ for use by common/assets.js
179-
test: require.resolve('./build/generate_asset_map.js'),
179+
test: require.resolve('./common/generate_asset_map.js'),
180180
use: ['babel-loader', 'val-loader']
181181
}
182182
]

0 commit comments

Comments
 (0)