Skip to content

Commit

Permalink
restructure, make independent from host, prevent pollution of host
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmruder committed Nov 7, 2022
1 parent 0900441 commit f6fc310
Show file tree
Hide file tree
Showing 28 changed files with 835 additions and 723 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
.timestamp-install

41 changes: 31 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
ARG NODE_VERSION="16-slim"
FROM registry.puzzle.ch/docker.io/node:${NODE_VERSION} as dev
ARG NODE_VERSION="18.10"
FROM node:${NODE_VERSION} as qwc2_base

ARG QWC2_VERSION_HASH="86ba224001cd3c9813ad645f4ccf4de7a17db801"
ARG QWC2_DOWNLOAD_PATH="https://github.com/qgis/qwc2/archive/$QWC2_VERSION_HASH.zip"
RUN apt-get update && apt-get install -y \
bash \
curl && \
curl -L -O $QWC2_DOWNLOAD_PATH && \
unzip $QWC2_VERSION_HASH.zip && \
rm $QWC2_VERSION_HASH.zip && \
mv qwc2-$QWC2_VERSION_HASH /qwc2 && \
echo "$QWC2_VERSION_HASH" > /qwc2/.qwc2.version.txt && \
echo "$QWC2_DOWNLOAD_PATH" > /qwc2/.qwc2.download_source.txt

COPY ./app/.yarnrc /qwc2

WORKDIR /qwc2

RUN yarn install

FROM qwc2_base as dev

ENV DEV_SERVER_PORT=8080

STOPSIGNAL SIGINT
RUN apt update && apt install -y \
make \
bash \
git
WORKDIR /app

STOPSIGNAL SIGINT
RUN apt-get update && apt-get install -y \
make

CMD ["/usr/bin/make", "clean", "serve-dev"]

#==============
Expand All @@ -16,7 +37,7 @@ CMD ["/usr/bin/make", "clean", "serve-dev"]

FROM dev as builder

COPY app/ /app
COPY ./app /app

WORKDIR /app

Expand All @@ -26,7 +47,7 @@ RUN /usr/bin/make clean build
# Stage prod
#==============

FROM registry.puzzle.ch/docker.io/nginx:stable as prod
FROM nginx:1.23.2 as prod

COPY --from=builder /app/prod /usr/share/nginx/html

COPY ./example_config/config.json ./example_config/themes.json /usr/share/nginx/html/
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ Administration => Kunde/opengis
Rechte
Daten
Konfiguration


```shell
docker build -t qwc2_minimal:latest --target prod .
docker build -t qwc2_minimal:latest-builder --target builder .
```

```shell
docker run --rm -v $(pwd)/example_config/themes.json:/app/static/themes.json -v $(pwd)/example_config/themesConfig.json:/app/themesConfig.json -u $(id -u):$(id -g) qwc2_minimal:latest-builder npm run themesconfig
```


```shell
docker run --rm -p 80:80 qwc2_minimal:latest
```


3 changes: 3 additions & 0 deletions app/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.png binary
*.ico binary
*.jpg binary
1 change: 0 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ dist/
prod/
icons/build
npm-debug.log
themes.json
static/assets/img/genmapthumbs/*
yarn-error.log
1 change: 1 addition & 0 deletions app/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--modules-folder /node_modules
36 changes: 15 additions & 21 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
QWC2_VERSION_HASH="86ba224001cd3c9813ad645f4ccf4de7a17db801"
QWC2_REPO_URL="https://github.com/qgis/qwc2.git"
QWC2_FOLDER="qwc2"

qwc2/.timestamp-clone:
git clone $(QWC2_REPO_URL) $(QWC2_FOLDER)
touch $@

qwc2/.timestamp-checkout: qwc2/.timestamp-clone
cd $(QWC2_FOLDER) && git checkout $(QWC2_VERSION_HASH)

node_modules/.timestamp-install: qwc2/.timestamp-checkout
yarn install
touch $@

prod/.timestamp-build: node_modules/.timestamp-install
npm run tsupdate
npm run iconfont
# npm run themesconfig
QWC2_VERSION_HASH=$(shell cat /qwc2/.qwc2.version.txt)
QWC2_REPO_URL=$(shell cat /qwc2/.qwc2.download_source.txt)

node_modules/webpack/bin/webpack.js --mode production --progress
prod/.timestamp-build: install
node /qwc2/scripts/updateTranslations.js
node /qwc2/scripts/makeIconkit.js
/node_modules/webpack/bin/webpack.js --mode production --progress
echo "<!-- Built: $(shell date -R) -->" >> ./prod/index.html
echo "<!-- Built: $(QWC2_VERSION_HASH) -->" >> ./prod/index.html
echo "<!-- Built: $(QWC2_REPO_URL) -->" >> ./prod/index.html
Expand All @@ -28,11 +15,14 @@ prod/.timestamp-build: node_modules/.timestamp-install
touch $@

.PHONY: install
install: node_modules/.timestamp-install
install: package.json
yarn install

.PHONY: serve-dev
serve-dev: install
yarn start
node /qwc2/scripts/updateTranslations.js
node /qwc2/scripts/makeIconkit.js
/node_modules/webpack/bin/webpack.js serve --mode development --progress --host 0.0.0.0 --port $(DEV_SERVER_PORT)

.PHONY: clean
clean:
Expand All @@ -44,3 +34,7 @@ clean:

.PHONY: build
build: prod/.timestamp-build

.PHONY: generate-themes
generate-themes: themesConfig.json
node /qwc2/scripts/themesConfig.js
74 changes: 37 additions & 37 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"name": "QWC2App",
"version": "2021.11.24",
"description": "QGIS Web Client 2 application",
"author": "Sourcepole",
"license": "BSD-2-Clause",
"repository": "[email protected]:sourcepole/qwc2-demo-app.git",
"private": true,
"workspaces": [
"qwc2"
],
"devDependencies": {
"babel-loader": "8.2.3",
"css-loader": "6.4.0",
"eslint": "7.32.0",
"eslint-plugin-react": "7.26.1",
"source-map-loader": "3.0.0",
"string-replace-loader": "3.0.3",
"style-loader": "3.3.1",
"webpack": "5.59.1",
"webpack-bundle-size-analyzer": "3.1.0",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.3.1",
"html-webpack-plugin": "5.4.0",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "9.0.0"
},
"scripts": {
"prod": "webpack --mode production --progress",
"start": "webpack serve --mode development --progress --host 0.0.0.0 --port 8081",
"report": "webpack --profile -m static > stats.html",
"iconfont": "node qwc2/scripts/makeIconkit.js",
"themesconfig": "node qwc2/scripts/themesConfig.js",
"tsupdate": "node qwc2/scripts/updateTranslations.js",
"build": "npm run prod",
"analyze": "webpack --mode production --json | webpack-bundle-size-analyzer",
"release": "node -e \"process.exit(require('os').platform() === 'win32' ? 0 : 1)\" && qwc2\\scripts\\package-commands.bat release || ./qwc2/scripts/package-commands.sh release"
}
"name": "QWC2App",
"version": "2021.11.24",
"description": "QGIS Web Client 2 application",
"author": "Sourcepole",
"license": "BSD-2-Clause",
"repository": "[email protected]:sourcepole/qwc2-demo-app.git",
"private": true,
"workspaces": [
"../qwc2"
],
"devDependencies": {
"babel-loader": "8.2.3",
"css-loader": "6.4.0",
"eslint": "7.32.0",
"eslint-plugin-react": "7.26.1",
"source-map-loader": "3.0.0",
"string-replace-loader": "3.0.3",
"style-loader": "3.3.1",
"webpack": "5.59.1",
"webpack-bundle-size-analyzer": "3.1.0",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.3.1",
"html-webpack-plugin": "5.4.0",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "9.0.0"
},
"scripts": {
"analyze": "/node_modules/webpack/bin/webpack.js --mode production --json | webpack-bundle-size-analyzer",
"start": "/node_modules/webpack/bin/webpack.js serve --mode development --progress --host 0.0.0.0 --port 8081",
"build": "npm run prod",
"prod": "/node_modules/webpack/bin/webpack.js --mode production --progress",
"release": "/qwc2/scripts/package-commands.sh release",
"report": "/node_modules/webpack/bin/webpack.js --profile -m static > stats.html",
"themesconfig": "node /qwc2/scripts/themesConfig.js",
"tsupdate": "node /qwc2/scripts/updateTranslations.js",
"iconfont": "node /qwc2/scripts/makeIconkit.js"
}
}
Binary file added app/static/assets/img/mapthumbs/bauprojekte.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f6fc310

Please sign in to comment.