feat(docker): created fxa-builder docker image

This adds a base node image and builder image so
that all our service images can share the same
common base, be smaller, and require less customization.
This commit is contained in:
Danny Coates 2020-04-20 18:40:28 -07:00
Родитель ea08b28afe
Коммит d4da8a3606
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C442633C62E00CB
59 изменённых файлов: 18849 добавлений и 490 удалений

Просмотреть файл

@ -8,7 +8,7 @@ cd "$DIR/.."
npm ci --ignore-scripts --no-optional --only=prod
node .circleci/modules-to-test.js | tee packages/test.list
./.circleci/assert-branch.sh
./.circleci/create-version-json.sh
./_scripts/create-version-json.sh
# only run a full npm install if required
if [[ "$MODULE" == "all" ]] || grep -e "$MODULE" -e 'all' packages/test.list > /dev/null; then

Просмотреть файл

@ -3,12 +3,13 @@
DIR=$(dirname "$0")
cd "$DIR"
./create-version-json.sh
if [[ -n "${CIRCLECI}" ]]; then
echo "Docker logs are located in the CircleCI build artifacts"
fi
../_scripts/build-builder.sh
../_scripts/build-fxa-node.sh
for d in ../packages/*/ ; do
./build.sh "$(basename "$d")"
done

Просмотреть файл

@ -11,24 +11,14 @@ if grep -e "$MODULE" -e 'all' "$DIR/../packages/test.list" > /dev/null; then
echo "# building $MODULE"
echo -e "################################\n"
# Place version.json so it is available as `/app/version.json` in the
# container, and also as `/app/config/version.json`, creating /app/config
# if needed.
cp ../version.json .
mkdir -p config
cp ../version.json config
mkdir -p ../../artifacts
ODDBALLS=("fxa-admin-panel" "fxa-auth-server" "fxa-content-server" "fxa-profile-server" "fxa-payments-server")
if [[ -x scripts/build-ci.sh ]]; then
time ./scripts/build-ci.sh
elif [[ "${ODDBALLS[*]}" =~ ${MODULE} ]]; then
cd ..
time docker build --progress=plain -f "${MODULE}/Dockerfile" -t "${MODULE}:build" . > "../artifacts/${MODULE}.log"
elif [[ -r Dockerfile ]]; then
time docker build --progress=plain -t "${MODULE}:build" . > "../../artifacts/${MODULE}.log"
# send Dockerfile over stdin to exclude local context
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#pipe-dockerfile-through-stdin
time (< Dockerfile docker build --progress=plain -t "${MODULE}:build" - &> "../../artifacts/${MODULE}.log")
fi
# for debugging:

21
.dockerignore Normal file
Просмотреть файл

@ -0,0 +1,21 @@
.circleci
.vscode
.git
**/coverage
**/docs
**/node_modules
#**/test
**/tests
**/.nyc_output
**/fxa-content-server-l10n
packages/*/build
packages/*/static/bower_components
packages/fxa-auth-server/.mail_output
!packages/fxa-auth-server/docs/pushpayloads.schema.json
packages/fxa-amplitude-send
packages/fxa-circleci
packages/fxa-dev-launcher
packages/fxa-email-event-proxy
packages/fxa-email-service
packages/fxa-content-server/dist
packages/fxa-geodb/db

1
.gitignore поставляемый
Просмотреть файл

@ -93,6 +93,7 @@ packages/fxa-auth-server/*.swp
packages/fxa-auth-server/test/load/bin
packages/fxa-auth-server/test/load/lib*
packages/fxa-auth-server/test/load/include
packages/fxa-auth-server/test/scripts/bulk-mailer/nodemailer-mocks/test_output
packages/fxa-auth-server/*.pyc
packages/fxa-auth-server/server.pot
packages/fxa-auth-server/.mail_output

Просмотреть файл

@ -0,0 +1,23 @@
FROM node:12-slim
RUN set -x \
&& addgroup --gid 10001 app \
&& adduser --disabled-password \
--gecos '' \
--gid 10001 \
--home /build \
--uid 10001 \
app
RUN apt-get update && apt-get install -y \
git-core \
graphicsmagick \
python-setuptools \
python-dev \
build-essential \
zip \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=app:app . /fxa
USER app
WORKDIR /fxa
RUN _scripts/base-docker.sh

Просмотреть файл

@ -0,0 +1,166 @@
version: "3.7"
services:
# 123done:
# image: 123done:build
# command: node server.js
# environment:
# - CONFIG_123DONE=./config-local.json
# - NODE_ENV=dev
# - PORT=8080
# init: true
# ports:
# - "8080:8080"
browserid-verifier:
image: browserid-verifier:build
command: node server.js
environment:
- PORT=5050
- IP_ADDRESS=0.0.0.0
- FORCE_INSECURE_LOOKUP_OVER_HTTP=true
init: true
ports:
- "5050:5050"
authdb:
image: fxa-auth-db-mysql:build
entrypoint: /bin/bash -c
command: ["./check-mysql.sh 3306 mysql && node bin/db_patcher.js && node bin/server.js"]
environment:
- HOST=0.0.0.0
- PORT=8000
- NODE_ENV=dev
- MYSQL_HOST=mysql
- MYSQL_SLAVE_HOST=mysql
init: true
ports:
- "8000:8000"
depends_on:
- mysql
auth:
image: fxa-auth-server:build
entrypoint: /bin/bash -c
command: ["./check-mysql.sh 3306 mysql && node bin/key_server.js"]
environment:
- PORT=9000
- NODE_ENV=dev
- IP_ADDRESS=0.0.0.0
- DB=mysql
- CONFIG_FILES=config/secrets.json
- MYSQL_HOST=mysql
- MEMCACHE_METRICS_CONTEXT_ADDRESS=memcached:11211
- HTTPDB_URL=http://authdb:8000
- EMAIL_SERVICE_HOST=email
- REDIS_HOST=redis
- ACCESS_TOKEN_REDIS_HOST=redis
- SMTP_HOST=maildev
- SMTP_PORT=25
- SNS_TOPIC_ENDPOINT=http://goaws:4100
init: true
ports:
- "9000:9000"
depends_on:
- authdb
- redis
content:
image: fxa-content-server:build
command: node server/bin/fxa-content-server.js
environment:
- PORT=3030
- NODE_ENV=production
- FEATURE_FLAGS_REDIS_HOST=redis
- STATIC_DIRECTORY=dist
- PAGE_TEMPLATE_SUBDIRECTORY=dist
- CONFIG_FILES=server/config/local.json
init: true
ports:
- "3030:3030"
depends_on:
- redis
profile:
image: fxa-profile-server:build
entrypoint: /bin/bash -c
command: ["./check-mysql.sh 3306 mysql && node bin/server.js"]
environment:
- HOST=0.0.0.0
- PORT=1111
- DB=mysql
- NODE_ENV=development
- MYSQL_HOST=mysql
- WORKER_HOST=profile-worker
- WORKER_URL=http://profile-worker:1113
- REDIS_HOST=redis
- AUTH_SERVER_URL=http://auth:9000/v1
- OAUTH_SERVER_URL=http://auth:9000/v1
init: true
ports:
- "1111:1111"
depends_on:
- mysql
- memcached
profile-worker:
image: fxa-profile-server:build
entrypoint: /bin/bash -c
command: ["./check-mysql.sh 3306 mysql && node bin/worker.js"]
environment:
- WORKER_HOST=0.0.0.0
- WORKER_PORT=1113
- DB=mysql
- NODE_ENV=development
- MYSQL_HOST=mysql
- REDIS_HOST=redis
- AUTH_SERVER_URL=http://auth:9000/v1
- OAUTH_SERVER_URL=http://auth:9000/v1
init: true
ports:
- "1113:1113"
depends_on:
- mysql
- memcached
profile-static:
image: fxa-profile-server:build
entrypoint: /bin/bash -c
command: ["./check-mysql.sh 3306 mysql && node bin/_static.js"]
environment:
- HOST=0.0.0.0
# yes, port is intentionally set to 1111
- PORT=1111
- DB=mysql
- NODE_ENV=development
- MYSQL_HOST=mysql
init: true
ports:
- "1112:1112"
depends_on:
- mysql
- memcached
redis:
image: redis
mysql:
image: mysql/mysql-server:5.6
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_ROOT_HOST=%
- MYSQL_DATABASE=fxa
memcached:
image: memcached
maildev:
image: djfarrelly/maildev
ports:
- "1080:80"
goaws:
image: pafortin/goaws
pubsub:
image: knarz/pubsub-emulator:latest
ports:
- "8085:8085"
firestore:
image: jdlk7/firestore-emulator
ports:
- "9090:9090"
email:
image: mozilla/fxa-email-service
environment:
- NODE_ENV=dev
- FXA_EMAIL_ENV=dev
- FXA_EMAIL_LOG_LEVEL=debug
ports:
- "8001:8001"

Просмотреть файл

@ -0,0 +1,17 @@
FROM node:12-slim
RUN set -x \
&& addgroup --gid 10001 app \
&& adduser --disabled-password \
--gecos '' \
--gid 10001 \
--home /build \
--uid 10001 \
app
RUN apt-get update && apt-get install -y \
netcat \
&& rm -rf /var/lib/apt/lists/*
COPY --from=fxa-builder:latest --chown=app:app /fxa/_scripts/check-mysql.sh /app/
USER app
WORKDIR /app

13
_scripts/base-docker.sh Executable file
Просмотреть файл

@ -0,0 +1,13 @@
#!/bin/bash -ex
DIR=$(dirname "$0")
cd "$DIR/.."
for d in ./packages/*/ ; do
(cd "$d" && mkdir -p config && cp ../version.json . && cp ../version.json config)
done
npm i lerna
npx lerna bootstrap --hoist pm2
npx lerna run --stream build
npx lerna exec --stream --concurrency 2 --no-bail -- npm prune --production

11
_scripts/build-builder.sh Executable file
Просмотреть файл

@ -0,0 +1,11 @@
#!/bin/bash -e
DIR=$(dirname "$0")
cd "$DIR"
./create-version-json.sh
mkdir -p ../artifacts
echo "Building fxa-builder image..."
time (cd .. && docker build -f _dev/docker/builder/Dockerfile -t fxa-builder:latest . &> "artifacts/fxa-builder.log")

9
_scripts/build-fxa-node.sh Executable file
Просмотреть файл

@ -0,0 +1,9 @@
#!/bin/bash -e
DIR=$(dirname "$0")
cd "$DIR"
mkdir -p ../artifacts
echo "Building fxa-node image..."
time (< ../_dev/docker/node/Dockerfile docker build -t fxa-node:latest - &> "../artifacts/fxa-node.log")

Просмотреть файл

@ -1,9 +1,10 @@
#!/bin/bash -e
PORT=${1:-3306}
HOST=${2:-localhost}
RETRY=60
for i in $(eval echo "{1..$RETRY}"); do
if echo PING | nc localhost "$PORT" | grep -q 'mysql'; then
if echo PING | nc "$HOST" "$PORT" | grep -q 'mysql'; then
exit 0
else
if [ "$i" -lt $RETRY ]; then

Просмотреть файл

Просмотреть файл

@ -6,7 +6,7 @@ if [ "${SKIP_PACKAGES}" != "true" ]; then
if [ "${CI}" = "true" ]; then
# it seems the filesystem on circleci can't handle full concurrency
npx lerna exec --concurrency 6 --ignore fxa-amplitude-send -- npm ci
npx lerna bootstrap --hoist pm2 --concurrency 6 --ignore fxa-amplitude-send
else
npx lerna bootstrap --hoist pm2
fi

Просмотреть файл

@ -49,7 +49,6 @@
"fxa-js-client",
"fxa-shared",
"fxa-profile-server",
"fxa-oauth-server",
"fxa-payments-server"
],
"fxa-auth-server": [

Просмотреть файл

@ -1,5 +0,0 @@
*~
node_modules
public-key.json
secret-key.json
static/bower_components

Просмотреть файл

@ -1,24 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
# as root
RUN apk update
RUN apk add g++ git
RUN npm install -g bower
RUN addgroup -g 10001 app && adduser -D -G app -h /app -u 10001 app
WORKDIR /app
USER app
# as app
COPY package.json package.json
COPY bower.json bower.json
COPY .bowerrc .bowerrc
RUN npm install
RUN /bin/rm -rf .npm
COPY . /app
USER root
RUN apk del -r g++ git
CMD node ./server.js
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/123done /app

Просмотреть файл

@ -1,5 +0,0 @@
.git
node_modules/*
*.log
loadtest/venv

Просмотреть файл

@ -1,21 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
# add a non-privileged user for installing and running
# the application
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
# Install node requirements and clean up temporary files
COPY package.json package.json
RUN apk add --update build-base ca-certificates git python gmp-dev && \
npm --loglevel warn install && \
npm cache clear --force && \
apk del --purge build-base gcc git python && \
rm -rf ~app/.node-gyp && \
rm -rf ~app/.npm
COPY . /app
USER app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/browserid-verifier /app

Просмотреть файл

@ -1,5 +0,0 @@
*~
node_modules
public-key.json
secret-key.json
static/bower_components

Просмотреть файл

@ -1,24 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
# as root
RUN apk update
RUN apk add g++ git
RUN npm install -g bower
RUN addgroup -g 10001 app && adduser -D -G app -h /app -u 10001 app
WORKDIR /app
USER app
# as app
COPY package.json package.json
COPY bower.json bower.json
COPY .bowerrc .bowerrc
RUN npm install
RUN /bin/rm -rf .npm
COPY . /app
USER root
RUN apk del -r g++ git
CMD node ./server.js
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fortress /app

Просмотреть файл

@ -1,23 +1,3 @@
# Build image
FROM node:12 as builder
FROM fxa-node:latest
COPY fxa-admin-panel /app
COPY fxa-components /fxa-components
WORKDIR /fxa-components
RUN npm ci
WORKDIR /app
RUN npm ci
ENV PUBLIC_URL /
ENV INLINE_RUNTIME_CHUNK false
RUN npm run build
RUN npm ci --production
# Production image
FROM node:12-slim
WORKDIR /app
USER node
COPY --from=builder --chown=node /app/build ./build/
COPY --from=builder --chown=node /app/node_modules ./node_modules/
COPY --from=builder --chown=node /app/version.json /app/version.json
COPY --chown=node fxa-admin-panel/package* ./
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-admin-panel /app

4282
packages/fxa-admin-panel/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,7 +8,7 @@
"restart": "pm2 restart pm2.config.js",
"lint:eslint": "eslint .",
"build": "npm-run-all build:client build:server",
"build:client": "rescripts build",
"build:client": "INLINE_RUNTIME_CHUNK=false rescripts build",
"build:server": "tsc -p server/tsconfig.json",
"test": "npm-run-all test:*",
"test:frontend": "rescripts test --coverage --verbose",
@ -23,6 +23,7 @@
"dateformat": "^3.0.3",
"express": "^4.17.1",
"express-http-proxy": "^1.6.0",
"fxa-components": "file:../fxa-components",
"graphql": "^14.6.0",
"helmet": "^3.21.3",
"mozlog": "^2.2.0",

Просмотреть файл

@ -2,11 +2,13 @@
DIR=$(dirname "$0")
cd $DIR/../../fxa-components
npm ci
cd "$DIR/../../../"
cd ../fxa-admin-panel
npm ci
npx lerna bootstrap \
--scope fxa-components \
--scope fxa-admin-panel
cd packages/fxa-admin-panel
PUBLIC_URL=/ INLINE_RUNTIME_CHUNK=false CI=false npm run build
CI=yes npm test

Просмотреть файл

@ -1,2 +0,0 @@
.git
.tscache

Просмотреть файл

@ -1,17 +1,3 @@
# Build image
FROM node:12 as builder
WORKDIR /app
COPY . /app
RUN npm ci
RUN npm run build
RUN npm ci --production
FROM fxa-node:latest
# Production image
FROM node:12-slim
WORKDIR /app
USER node
COPY --from=builder --chown=node /app/dist ./dist/
COPY --from=builder --chown=node /app/node_modules ./node_modules/
COPY --from=builder --chown=node /app/version.json /app/version.json
COPY --chown=node config/*.json ./config/
COPY --chown=node package* ./
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-admin-server /app

Просмотреть файл

@ -1,2 +0,0 @@
.git
node_modules

Просмотреть файл

@ -1 +0,0 @@
.git

Просмотреть файл

@ -1,21 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
RUN apk add --no-cache make git gcc g++ python
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
# S3 bucket in Cloud Services prod IAM
ADD https://s3.amazonaws.com/dumb-init-dist/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
USER app
COPY package-lock.json package-lock.json
COPY package.json package.json
RUN npm install --production && rm -rf ~app/.npm
COPY . /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-auth-db-mysql /app

Просмотреть файл

@ -1 +0,0 @@
.git

Просмотреть файл

@ -1,30 +1,5 @@
FROM node:12-slim
FROM fxa-node:latest
RUN set -x \
&& 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 python build-essential
COPY --chown=app:app fxa-auth-server /app
COPY --chown=app:app ["fxa-geodb", "../fxa-geodb/"]
COPY --chown=app:app ["fxa-shared", "../fxa-shared/"]
USER app
WORKDIR /fxa-geodb
RUN npm ci
WORKDIR /fxa-shared
RUN npm ci
WORKDIR /app
RUN npm ci --production && rm -rf ~app/.npm
RUN node scripts/gen_keys.js
RUN NODE_ENV=dev node scripts/oauth_gen_keys.js
RUN node scripts/gen_vapid_keys.js
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-auth-server /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-geodb /fxa-geodb
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-shared /fxa-shared

6482
packages/fxa-auth-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,6 +9,7 @@
"test": "test"
},
"scripts": {
"build": "NODE_ENV=dev npm run gen-keys",
"bump-template-versions": "node scripts/template-version-bump",
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
@ -19,7 +20,7 @@
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"test": "VERIFIER_VERSION=0 scripts/test-local.sh",
"test-ci": "npm run gen-keys && scripts/test-local.sh && npm run test-e2e",
"test-ci": "scripts/test-local.sh && npm run test-e2e",
"test-e2e": "NODE_ENV=dev mocha test/e2e",
"test-scripts": "NODE_ENV=dev mocha test/scripts --exit",
"test-remote": "MAILER_HOST=restmail.net MAILER_PORT=80 CORS_ORIGIN=http://baz mocha --timeout=300000 test/remote",
@ -56,8 +57,10 @@
"commander": "2.18.0",
"convict": "4.3.1",
"email-addresses": "2.0.2",
"fxa-geodb": "file:../fxa-geodb",
"fxa-jwtool": "0.7.2",
"fxa-notifier-aws": "1.0.0",
"fxa-shared": "file:../fxa-shared",
"google-libphonenumber": "^3.2.7",
"handlebars": "^4.5.3",
"hapi-error": "^2.3.0",
@ -73,7 +76,7 @@
"mozlog": "2.2.0",
"mysql": "2.15.0",
"mysql-patcher": "0.7.0",
"node-uap": "git+https://github.com/vladikoff/node-uap.git#9cdd16247",
"node-uap": "git+https://github.com/dannycoates/node-uap.git#96dc1f9f224422ec184395b6408cd1fc40ee452a",
"node-zendesk": "^1.4.0",
"nodemailer": "2.7.2",
"otplib": "11.0.1",

Просмотреть файл

@ -2,15 +2,14 @@
DIR=$(dirname "$0")
cd $DIR/../../fxa-geodb
npm ci
cd "$DIR/../../../"
cd ../fxa-shared
npm ci
npx lerna bootstrap \
--scope fxa-shared \
--scope fxa-geodb \
--scope fxa-auth-db-mysql \
--scope fxa-auth-server \
--concurrency 2
cd ../fxa-auth-db-mysql
npm ci
cd ../fxa-auth-server
npm ci
cd packages/fxa-auth-server
npm run test-ci

Просмотреть файл

@ -1,37 +1,5 @@
FROM node:12-slim AS builder
FROM fxa-node:latest
RUN set -x \
&& addgroup --gid 10001 app \
&& adduser --disabled-password \
--gecos '' \
--gid 10001 \
--home /app \
--uid 10001 \
app
RUN apt-get update && apt-get install -y \
git-core \
python-setuptools \
python-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
USER app
COPY --chown=app:app fxa-content-server /app
WORKDIR /app
RUN npm ci && rm -rf ~/.cache ~/.npm
COPY --chown=app:app ["fxa-geodb", "../fxa-geodb/"]
WORKDIR /fxa-geodb
RUN npm ci
COPY --chown=app:app ["fxa-shared", "../fxa-shared/"]
WORKDIR /fxa-shared
RUN npm ci
COPY --chown=app:app ["fxa-settings", "../fxa-settings/"]
WORKDIR /fxa-settings
RUN npm ci && npm run build
WORKDIR /app
RUN npm run build-production
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-content-server /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-geodb /fxa-geodb
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-shared /fxa-shared

Просмотреть файл

@ -3,7 +3,7 @@
"version": "1.167.1",
"description": "Firefox Accounts Content Server",
"scripts": {
"build-production": "NODE_ENV=production grunt build",
"build": "NODE_ENV=production grunt build",
"postinstall": "cp server/config/local.json-dist server/config/local.json && scripts/download_l10n.sh",
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
@ -67,8 +67,11 @@
"file-loader": "1.1.11",
"fxa-common-password-list": "0.0.4",
"fxa-crypto-relier": "2.3.0",
"fxa-geodb": "file:../fxa-geodb",
"fxa-mustache-loader": "0.0.2",
"fxa-pairing-channel": "1.0.1",
"fxa-settings": "file:../fxa-settings",
"fxa-shared": "file:../fxa-shared",
"got": "6.7.1",
"grunt": "^1.0.4",
"grunt-babel": "6.0.0",

Просмотреть файл

@ -1,16 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
RUN apk add --no-cache make git gcc g++ python
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
USER app
COPY --chown=app:app package-lock.json package-lock.json
COPY --chown=app:app package.json package.json
RUN npm ci --production && rm -rf ~app/.npm
COPY --chown=app:app . /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-customs-server /app

Просмотреть файл

@ -7,7 +7,7 @@
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
"test": "mocha --ui tdd --recursive tests/",
"test": "npm run lint && mocha --ui tdd --recursive tests/",
"build": "zip -q --recurse-paths -y fxa-email-event-proxy *.js *.json node_modules",
"format": "prettier '**' --write"
},

Просмотреть файл

@ -1,8 +0,0 @@
#!/bin/bash -ex
DIR=$(dirname "$0")
cd $DIR/..
npm ci
npm run lint
npm test

Просмотреть файл

@ -1,2 +0,0 @@
.git
.tscache

Просмотреть файл

@ -1,17 +1,3 @@
# Build image
FROM node:12 as builder
WORKDIR /app
COPY . /app
RUN npm ci
RUN npm run build
RUN npm ci --production
FROM fxa-node:latest
# Production image
FROM node:12-slim
WORKDIR /app
USER node
COPY --from=builder --chown=node /app/dist ./dist/
COPY --from=builder --chown=node /app/node_modules ./node_modules/
COPY --from=builder --chown=node /app/version.json /app/version.json
COPY --chown=node config/*.json ./config/
COPY --chown=node package* ./
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-event-broker /app

Просмотреть файл

@ -1,17 +1,3 @@
# Build image
FROM node:12 as builder
WORKDIR /app
COPY . /app
RUN npm ci
RUN npm run build
RUN npm ci --production
FROM fxa-node:latest
# Production image
FROM node:12-slim
WORKDIR /app
USER node
COPY --from=builder --chown=node /app/dist ./dist/
COPY --from=builder --chown=node /app/node_modules ./node_modules/
COPY --from=builder --chown=node /app/version.json /app/version.json
COPY --chown=node config/*.json ./config/
COPY --chown=node package* ./
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-graphql-api /app

Просмотреть файл

@ -1,30 +1,3 @@
# Build image
FROM node:12 as builder
COPY --chown=app:app ["fxa-shared/metrics/user-agent.js", "../fxa-shared/metrics/user-agent.js"]
COPY --chown=app:app ["fxa-shared/metrics/user-agent.d.ts", "../fxa-shared/metrics/user-agent.d.ts"]
COPY --chown=app:app ["fxa-shared/package.json", "../fxa-shared/package.json"]
COPY --chown=app:app ["fxa-shared/package-lock.json", "../fxa-shared/package-lock.json"]
# Also need to copy over the tsconfig.json, or the linter will fail
COPY --chown=app:app ["fxa-shared/tsconfig.json", "../fxa-shared/tsconfig.json"]
# And the linter also needs the nsprc...
COPY --chown=app:app ["fxa-shared/.nsprc", "../fxa-shared/.nsprc"]
RUN mkdir /fxa-shared/node_modules
WORKDIR /fxa-shared
USER app
RUN npm ci
FROM fxa-node:latest
WORKDIR /app
COPY . /app
RUN npm ci
RUN npm run build
RUN npm ci --production
# Production image
FROM node:12-slim
WORKDIR /app
USER node
COPY --from=builder --chown=node /app/dist ./dist/
COPY --from=builder --chown=node /app/node_modules ./node_modules/
COPY --from=builder --chown=node /app/version.json /app/version.json
COPY --chown=node config/*.json ./config/
COPY --chown=node package* ./
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-metrics-processor /app

Просмотреть файл

@ -1,64 +1,5 @@
FROM node:12-stretch AS node-builder
RUN groupadd --gid 10001 app && \
useradd --uid 10001 --gid 10001 --home /app --create-home app
RUN mkdir /fxa-content-server && chown -R app:app /fxa-content-server
USER app
WORKDIR /app
COPY --chown=app:app ["fxa-payments-server/package*.json", "./"]
RUN npm ci
COPY --chown=app:app ["fxa-payments-server/.storybook", ".storybook/"]
COPY --chown=app:app ["fxa-payments-server/public", "public/"]
COPY --chown=app:app ["fxa-payments-server/src", "src/"]
COPY --chown=app:app ["fxa-content-server", "../fxa-content-server/"]
WORKDIR /fxa-content-server
RUN npm ci
WORKDIR /app
ENV PUBLIC_URL /
ENV INLINE_RUNTIME_CHUNK false
RUN npm run build
FROM fxa-node:latest
FROM node:12-stretch-slim
RUN groupadd --gid 10001 app && \
useradd --uid 10001 --gid 10001 --home /app --create-home app
RUN apt-get -y update && apt-get -y install git && apt-get clean && rm -rf /var/lib/apt/lists
USER app
WORKDIR /app
COPY --chown=app:app --from=node-builder /app .
COPY --chown=app:app [ "fxa-payments-server/", "./" ]
COPY --chown=app:app ["fxa-geodb", "../fxa-geodb/"]
WORKDIR /fxa-geodb
USER app
RUN npm ci
# The fxa-shared install stanza below should be simplified:
# https://github.com/mozilla/fxa/issues/2937
# Borrowing this stanza from fxa-content-server/Dockerfile-build
# Except, to avoid installing redis, we're just copying over the files
# that are explicitly needed.
COPY --chown=app:app ["fxa-shared/metrics/user-agent.js", "../fxa-shared/metrics/user-agent.js"]
COPY --chown=app:app ["fxa-shared/metrics/amplitude-event.1.schema.json", "../fxa-shared/metrics/amplitude-event.1.schema.json"]
COPY --chown=app:app ["fxa-shared/metrics/amplitude.js", "../fxa-shared/metrics/amplitude.js"]
COPY --chown=app:app ["fxa-shared/metrics/flow-performance.js", "../fxa-shared/metrics/flow-performance.js"]
COPY --chown=app:app ["fxa-shared/express/index.js", "../fxa-shared/express/index.js"]
COPY --chown=app:app ["fxa-shared/express/routing.js", "../fxa-shared/express/routing.js"]
COPY --chown=app:app ["fxa-shared/express/cors.js", "../fxa-shared/express/cors.js"]
COPY --chown=app:app ["fxa-shared/express/remote-address.js", "../fxa-shared/express/remote-address.js"]
COPY --chown=app:app ["fxa-shared/express/geo-locate.js", "../fxa-shared/express/geo-locate.js"]
COPY --chown=app:app ["fxa-shared/package.json", "../fxa-shared/package.json"]
COPY --chown=app:app ["fxa-shared/package-lock.json", "../fxa-shared/package-lock.json"]
# Copy over one test, so npm run test won't barf
COPY --chown=app:app ["fxa-shared/test/metrics/amplitude.js", "../fxa-shared/test/metrics/amplitude.js"]
# Also need to copy over the tsconfig.json, or the linter will fail
COPY --chown=app:app ["fxa-shared/tsconfig.json", "../fxa-shared/tsconfig.json"]
# And the linter also needs the nsprc...
COPY --chown=app:app ["fxa-shared/.nsprc", "../fxa-shared/.nsprc"]
RUN mkdir /fxa-shared/node_modules
WORKDIR /fxa-shared
USER app
RUN npm ci
WORKDIR /app
CMD [ "/usr/local/bin/node", "server/bin/fxa-payments-server.js" ]
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-payments-server /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-geodb /fxa-geodb
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-shared /fxa-shared

Просмотреть файл

@ -10,7 +10,7 @@
"start": "pm2 start pm2.config.js",
"stop": "pm2 stop pm2.config.js",
"restart": "pm2 restart pm2.config.js",
"build": "react-scripts build",
"build": "INLINE_RUNTIME_CHUNK=false react-scripts build",
"eject": "react-scripts eject",
"test": "npm-run-all test:*",
"test:frontend": "react-scripts test --coverage --verbose",
@ -105,6 +105,8 @@
"dayjs": "^1.8.17",
"eslint-plugin-jest": "^22.21.0",
"express": "^4.16.4",
"fxa-geodb": "file:../fxa-geodb",
"fxa-shared": "file:../fxa-shared",
"intl-pluralrules": "^1.1.0",
"helmet": "3.21.1",
"hot-shots": "^7.0.0",

Просмотреть файл

@ -2,17 +2,18 @@
DIR=$(dirname "$0")
cd $DIR/../../fxa-content-server
npm ci
cd "$DIR/../../../"
cd ../fxa-geodb
npm ci
npx lerna bootstrap \
--scope fxa-shared \
--scope fxa-geodb \
--scope fxa-settings \
--scope fxa-content-server \
--scope fxa-payments-server \
--concurrency 2
cd ../fxa-shared
npm ci
cd packages/fxa-payments-server
cd ../fxa-payments-server
npm ci
# TODO rm the CI=false
PUBLIC_URL=/ INLINE_RUNTIME_CHUNK=false CI=false npm run build
CI=yes npm test

Просмотреть файл

@ -1 +0,0 @@
.git

Просмотреть файл

@ -1,46 +1,10 @@
FROM node:12-alpine AS builder
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
# S3 bucket in Cloud Services prod IAM
ADD https://s3.amazonaws.com/dumb-init-dist/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
RUN apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/community/ --no-cache graphicsmagick=1.3.35-r0 git && \
apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.9/community/ --no-cache --virtual .build-deps git python make g++
COPY --chown=app:app fxa-profile-server /app
COPY --chown=app:app ["fxa-shared", "../fxa-shared/"]
USER app
WORKDIR /app
RUN npm install --production && rm -rf ~app/.npm
WORKDIR /fxa-shared
RUN npm ci
FROM fxa-node:latest
USER root
RUN chown -R app:app /fxa-shared
USER app
# Build final image by copying from builder
FROM node:12-alpine
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
# S3 bucket in Cloud Services prod IAM
ADD https://s3.amazonaws.com/dumb-init-dist/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
RUN apk add --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/community/ --no-cache graphicsmagick=1.3.35-r0 git
RUN apt-get update && apt-get install -y \
graphicsmagick \
&& rm -rf /var/lib/apt/lists/*
USER app
COPY --from=builder --chown=app /app/ /app/
COPY --from=builder --chown=app /fxa-shared/ /fxa-shared/
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-profile-server /app
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-shared /fxa-shared

Просмотреть файл

@ -18,7 +18,6 @@ const conf = convict({
url: {
doc: 'URL of fxa-auth-server',
env: 'AUTH_SERVER_URL',
format: 'url',
default: 'http://localhost:9000/v1',
},
},
@ -198,7 +197,6 @@ const conf = convict({
oauth: {
url: {
doc: 'URL of fxa-oauth-server',
format: 'url',
env: 'OAUTH_SERVER_URL',
default: 'http://localhost:9000/v1',
},

3443
packages/fxa-profile-server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -27,6 +27,7 @@
"compute-cluster": "0.0.9",
"convict": "4.0.2",
"fxa-notifier-aws": "1.0.0",
"fxa-shared": "file:../fxa-shared",
"gm-reloaded": "1.24.0",
"@hapi/joi": "^17.1.1",
"@hapi/hapi": "19.1.1",

4282
packages/fxa-settings/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -11,6 +11,7 @@
"@types/node": "^12.12.35",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.6",
"fxa-components": "file:../fxa-components",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",

Просмотреть файл

@ -2,11 +2,13 @@
DIR=$(dirname "$0")
cd $DIR/../../fxa-components
npm ci
cd "$DIR/../../../"
cd ../fxa-settings
npm ci
npx lerna bootstrap \
--scope fxa-components \
--scope fxa-settings
cd packages/fxa-settings
PUBLIC_URL=/ INLINE_RUNTIME_CHUNK=false CI=false npm run build
CI=yes npm test

10
packages/fxa-shared/package-lock.json сгенерированный
Просмотреть файл

@ -2368,11 +2368,11 @@
}
},
"node-uap": {
"version": "git://github.com/vladikoff/node-uap.git#9cdd16247c8255d881820038d30db68b7926277d",
"from": "git://github.com/vladikoff/node-uap.git#9cdd16247",
"version": "git+https://github.com/dannycoates/node-uap.git#96dc1f9f224422ec184395b6408cd1fc40ee452a",
"from": "git+https://github.com/dannycoates/node-uap.git#96dc1f9f224422ec184395b6408cd1fc40ee452a",
"requires": {
"array.prototype.find": "2.0.0",
"uap-core": "git://github.com/ua-parser/uap-core.git",
"uap-core": "git://github.com/ua-parser/uap-core.git#2e6c983e42e7aae7d957a263cb4d3de7ccbd92af",
"uap-ref-impl": "0.2.0",
"yamlparser": "0.0.2"
}
@ -3593,8 +3593,8 @@
"dev": true
},
"uap-core": {
"version": "git://github.com/ua-parser/uap-core.git#286809e09706ea891b9434ed875574d65e0ff6b7",
"from": "git://github.com/ua-parser/uap-core.git"
"version": "git://github.com/ua-parser/uap-core.git#2e6c983e42e7aae7d957a263cb4d3de7ccbd92af",
"from": "git://github.com/ua-parser/uap-core.git#2e6c983e42e7aae7d957a263cb4d3de7ccbd92af"
},
"uap-ref-impl": {
"version": "0.2.0",

Просмотреть файл

@ -6,7 +6,7 @@
"scripts": {
"postinstall": "npm run build",
"build": "tsc",
"test": "node ./scripts/mocha-coverage.js -r ts-node/register --recursive test",
"test": "npm run lint && node ./scripts/mocha-coverage.js -r ts-node/register --recursive test",
"lint": "npm-run-all --parallel lint:*",
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
"lint:eslint": "eslint .",
@ -65,7 +65,7 @@
"joi": "^14.3.1",
"js-md5": "^0.7.3",
"moment": "^2.24.0",
"node-uap": "git://github.com/vladikoff/node-uap.git#9cdd16247",
"node-uap": "git+https://github.com/dannycoates/node-uap.git#96dc1f9f224422ec184395b6408cd1fc40ee452a",
"redis": "^2.8.0"
}
}

Просмотреть файл

@ -1,8 +0,0 @@
#!/bin/bash -ex
DIR=$(dirname "$0")
cd $DIR/..
npm ci
npm run lint
npm test

Просмотреть файл

@ -1,18 +1,3 @@
FROM node:12-alpine
FROM fxa-node:latest
# To handle 'not get uid/gid'
RUN npm config set unsafe-perm true
RUN apk add --no-cache git make gcc g++
RUN addgroup -g 10001 app && \
adduser -D -G app -h /app -u 10001 app
WORKDIR /app
USER app
COPY --chown=app:app . /app
RUN npm ci && rm -rf ~app/.npm
RUN npm run build
COPY --from=fxa-builder:latest --chown=app:app /fxa/packages/fxa-support-panel /app