diff --git a/Dockerfile b/Dockerfile index 113526aa..55d4d153 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,20 @@ RUN echo "Building with Endpoint ${MW_ENDPOINT} and Port ${MW_PORT}" RUN npm ci RUN npm run build +# 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 +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 +RUN ls -R ./packages/client-ng/dist + # Build Final Image FROM apline_container @@ -30,7 +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 /manniwatch/client +RUN ls -R /manniwatch/client ENV NODE_ENV="production" RUN npm ci --production && \ npm cache clean --force 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..fb696fbe 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 @@ -9,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, +}; diff --git a/package.json b/package.json index 23600d77..e4fca544 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": {