From 5c4d8b98b57d3f629f2c6e90842eff6c6abe619f Mon Sep 17 00:00:00 2001 From: donmahallem Date: Tue, 31 Aug 2021 00:29:53 +0200 Subject: [PATCH 1/8] build(docker): build manniwatch client --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Dockerfile b/Dockerfile index a19c6fc9..5b7befa8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,15 @@ RUN echo "Building with Endpoint ${MW_ENDPOINT} and Port ${MW_PORT}" RUN npm ci RUN npm run build +# Build server +FROM apline_container AS build_client + +WORKDIR /usr/src/app +RUN git clone https://github.com/manniwatch/manniwatch.git +RUN npm ci +RUN npx lerna bootstrap --ci --scope @donmahallem/client-ng --include-dependencies +RUN npx lerna run build --scope @donmahallem/client-ng --include-dependencies + # Build Final Image FROM apline_container @@ -30,6 +39,7 @@ WORKDIR /usr/src/app COPY --chown=node:node package*.json tsconfig*.json ./ COPY --chown=node:node ./src ./src COPY --from=build_server --chown=node:node /usr/src/app/dist ./dist +COPY --from=build_client --chown=node:node /usr/src/app/packages/client-ng/dist /usr/client ENV NODE_ENV="production" RUN npm ci --production && \ From cae7e3e77bb18db81e765fcb36ccfff5dd782832 Mon Sep 17 00:00:00 2001 From: donmahallem Date: Tue, 31 Aug 2021 00:33:18 +0200 Subject: [PATCH 2/8] fix(docker): use bullseye to build client --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5b7befa8..2e4f076a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN npm ci RUN npm run build # Build server -FROM apline_container AS build_client +FROM node:16.8-bullseye AS build_client WORKDIR /usr/src/app RUN git clone https://github.com/manniwatch/manniwatch.git From a910fe72e19a9db712fefcc9fa89e2c6b3621260 Mon Sep 17 00:00:00 2001 From: donmahallem Date: Tue, 31 Aug 2021 00:35:46 +0200 Subject: [PATCH 3/8] fix: fix git clone path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e4f076a..63ea464d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN npm run build FROM node:16.8-bullseye AS build_client WORKDIR /usr/src/app -RUN git clone https://github.com/manniwatch/manniwatch.git +RUN git clone https://github.com/manniwatch/manniwatch.git ./ RUN npm ci RUN npx lerna bootstrap --ci --scope @donmahallem/client-ng --include-dependencies RUN npx lerna run build --scope @donmahallem/client-ng --include-dependencies From 838088f31a59968ffe468654a6ec0e2737827439 Mon Sep 17 00:00:00 2001 From: donmahallem Date: Tue, 31 Aug 2021 00:47:05 +0200 Subject: [PATCH 4/8] chore: fix typo --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63ea464d..f04a7525 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ FROM node:16.8-bullseye AS build_client WORKDIR /usr/src/app RUN git clone https://github.com/manniwatch/manniwatch.git ./ RUN npm ci -RUN npx lerna bootstrap --ci --scope @donmahallem/client-ng --include-dependencies -RUN npx lerna run build --scope @donmahallem/client-ng --include-dependencies +RUN npx lerna bootstrap --ci --scope @manniwatch/client-ng --include-dependencies +RUN npx lerna run build --scope @manniwatch/client-ng --include-dependencies # Build Final Image FROM apline_container From 827e6047bbfbff02f7e27067cf0255ee310134db Mon Sep 17 00:00:00 2001 From: donmahallem Date: Tue, 31 Aug 2021 08:16:48 +0200 Subject: [PATCH 5/8] fix: use example environment.ts --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f04a7525..53af8866 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ WORKDIR /usr/src/app RUN git clone https://github.com/manniwatch/manniwatch.git ./ RUN npm ci RUN npx lerna bootstrap --ci --scope @manniwatch/client-ng --include-dependencies +RUN cp ./packages/client-ng/src/environments/environment.example.ts packages/client-ng/src/environments/environment.ts RUN npx lerna run build --scope @manniwatch/client-ng --include-dependencies # Build Final Image @@ -39,7 +40,7 @@ WORKDIR /usr/src/app COPY --chown=node:node package*.json tsconfig*.json ./ COPY --chown=node:node ./src ./src COPY --from=build_server --chown=node:node /usr/src/app/dist ./dist -COPY --from=build_client --chown=node:node /usr/src/app/packages/client-ng/dist /usr/client +COPY --from=build_client --chown=node:node /usr/src/app/packages/client-ng/dist/manniwatch /usr/client ENV NODE_ENV="production" RUN npm ci --production && \ From b5d88aab3755d5e32f5f190a64874272c9e0b335 Mon Sep 17 00:00:00 2001 From: DonMahallem Date: Mon, 6 Sep 2021 18:56:15 +0200 Subject: [PATCH 6/8] build(docker): production build of manniwatch web client --- Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 53af8866..e219afb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,9 +22,13 @@ FROM node:16.8-bullseye AS build_client WORKDIR /usr/src/app RUN git clone https://github.com/manniwatch/manniwatch.git ./ RUN npm ci -RUN npx lerna bootstrap --ci --scope @manniwatch/client-ng --include-dependencies +RUN npx lerna bootstrap --ci --scope @manniwatch/client-ng --include-dependencies --concurrency=1 RUN cp ./packages/client-ng/src/environments/environment.example.ts packages/client-ng/src/environments/environment.ts -RUN npx lerna run build --scope @manniwatch/client-ng --include-dependencies +RUN cp ./packages/client-ng/src/environments/environment.example.ts packages/client-ng/src/environments/environment.prod.ts +RUN npx lerna run build $(npx lerna ls --scope @manniwatch/client-ng --include-dependencies | grep -v '^@manniwatch/client-ng$' | xargs -n1 echo '--scope') --stream +RUN npx lerna run build:pug --scope=@manniwatch/client-ng +RUN npx lerna run build:release --scope=@manniwatch/client-ng +RUN ls -R ./packages/client-ng/dist # Build Final Image FROM apline_container @@ -40,8 +44,8 @@ WORKDIR /usr/src/app COPY --chown=node:node package*.json tsconfig*.json ./ COPY --chown=node:node ./src ./src COPY --from=build_server --chown=node:node /usr/src/app/dist ./dist -COPY --from=build_client --chown=node:node /usr/src/app/packages/client-ng/dist/manniwatch /usr/client - +COPY --from=build_client --chown=node:node /usr/src/app/packages/client-ng/dist/manniwatch /manniwatch/client +RUN ls -R /manniwatch/client ENV NODE_ENV="production" RUN npm ci --production && \ npm cache clean --force From 507b339f314106bb54791e0c8e9ad4461c4c0971 Mon Sep 17 00:00:00 2001 From: DonMahallem Date: Mon, 6 Sep 2021 18:59:10 +0200 Subject: [PATCH 7/8] chore: add compose scripts --- docker-compose-full.yml | 3 +++ docker-compose.yml | 1 + package.json | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 docker-compose-full.yml diff --git a/docker-compose-full.yml b/docker-compose-full.yml new file mode 100644 index 00000000..d7a5f839 --- /dev/null +++ b/docker-compose-full.yml @@ -0,0 +1,3 @@ +services: + web: + command: full diff --git a/docker-compose.yml b/docker-compose.yml index 6bed8070..bf22c037 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: "3.9" services: web: container_name: manniwatch_web_server + image: manniwatch/test build: . stop_signal: SIGINT init: true diff --git a/package.json b/package.json index f3fce691..b5472ff0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "lint:fix": "eslint -c .eslintrc.js --ext .ts ./src --fix", "postlint:fix": "prettier --config .prettierrc src/**/*.ts src/*.ts --write", "docs": "typedoc --options ../../typedoc.json", - "prepublishOnly": "npm run test && npm run docs && npm run build" + "prepublishOnly": "npm run test && npm run docs && npm run build", + "compose:api": "docker compose -f docker-compose.yml up", + "compose:full": "docker compose -f docker-compose.yml -f docker-compose-full.yml up" }, "homepage": "https://manniwatch.github.io/docker/", "author": { From feaeca4ad7ae3f6917d275bd2bde07a759ecfb19 Mon Sep 17 00:00:00 2001 From: DonMahallem Date: Mon, 6 Sep 2021 22:34:58 +0200 Subject: [PATCH 8/8] fix: environment file copy --- Dockerfile | 6 +++--- docker-compose.yml | 1 + extra/README.md | 1 + extra/environment.example.ts | 31 +++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 extra/README.md create mode 100644 extra/environment.example.ts diff --git a/Dockerfile b/Dockerfile index e219afb8..eb1b1cee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,15 +16,15 @@ RUN echo "Building with Endpoint ${MW_ENDPOINT} and Port ${MW_PORT}" RUN npm ci RUN npm run build -# Build server +# Build client FROM node:16.8-bullseye AS build_client WORKDIR /usr/src/app RUN git clone https://github.com/manniwatch/manniwatch.git ./ RUN npm ci RUN npx lerna bootstrap --ci --scope @manniwatch/client-ng --include-dependencies --concurrency=1 -RUN cp ./packages/client-ng/src/environments/environment.example.ts packages/client-ng/src/environments/environment.ts -RUN cp ./packages/client-ng/src/environments/environment.example.ts packages/client-ng/src/environments/environment.prod.ts +COPY --chown=node:node ./extra/environment.example.ts packages/client-ng/src/environments/environment.ts +COPY --chown=node:node ./extra/environment.example.ts packages/client-ng/src/environments/environment.prod.ts RUN npx lerna run build $(npx lerna ls --scope @manniwatch/client-ng --include-dependencies | grep -v '^@manniwatch/client-ng$' | xargs -n1 echo '--scope') --stream RUN npx lerna run build:pug --scope=@manniwatch/client-ng RUN npx lerna run build:release --scope=@manniwatch/client-ng diff --git a/docker-compose.yml b/docker-compose.yml index bf22c037..fb696fbe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,3 +10,4 @@ services: - "4200:3000" environment: NODE_ENV: production + MW_ENDPOINT: https://kvg-kiel.de diff --git a/extra/README.md b/extra/README.md new file mode 100644 index 00000000..fa6b76bd --- /dev/null +++ b/extra/README.md @@ -0,0 +1 @@ +# Files needed to build docker image diff --git a/extra/environment.example.ts b/extra/environment.example.ts new file mode 100644 index 00000000..3f2ec0f9 --- /dev/null +++ b/extra/environment.example.ts @@ -0,0 +1,31 @@ +/*! + * Source https://github.com/manniwatch/manniwatch Package: client-ng + */ + +import { IEnvironmentBase } from '@manniwatch/client-types'; +import MVT from 'ol/format/MVT'; + +export const environment: IEnvironmentBase = { + apiEndpoint: '/api/', + map: { + center: { + lat: 0, + lon: 0, + }, + mapProvider: { + options: { + format: new MVT(), + maxZoom: 14, + /** + * Please replace with correct url + * This one doesnt work! + */ + url: 'https://manniwatch.github.io/tiles/{z}/{x}/{y}.pbf', + }, + type: 'vector', + }, + zoom: 0, + }, + production: true, + pwa: false, +};