diff options
| -rw-r--r-- | .dockerignore | 2 | ||||
| -rw-r--r-- | .gitlab-ci.yml | 2 | ||||
| -rw-r--r-- | Dockerfile.production | 12 | ||||
| -rw-r--r-- | main.py | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/.dockerignore b/.dockerignore index 6f3416a..e2eb2a4 100644 --- a/.dockerignore +++ b/.dockerignore | |||
| @@ -2,6 +2,4 @@ uploads | |||
| 2 | node_modules | 2 | node_modules |
| 3 | static/dist | 3 | static/dist |
| 4 | static/.webassets-cache | 4 | static/.webassets-cache |
| 5 | *.js | ||
| 6 | *.json | ||
| 7 | *.md \ No newline at end of file | 5 | *.md \ No newline at end of file |
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dd34900..0369d3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml | |||
| @@ -36,8 +36,6 @@ tests:debian: | |||
| 36 | stage: test | 36 | stage: test |
| 37 | before_script: | 37 | before_script: |
| 38 | - apt update | 38 | - apt update |
| 39 | - apt install nodejs npm | ||
| 40 | - npm install --global postcss | ||
| 41 | script: | 39 | script: |
| 42 | - apt-get -qqy update | 40 | - apt-get -qqy update |
| 43 | - apt-get -qqy install --no-install-recommends mat2 python3-flask python3-coverage python3-pip python3-setuptools | 41 | - apt-get -qqy install --no-install-recommends mat2 python3-flask python3-coverage python3-pip python3-setuptools |
diff --git a/Dockerfile.production b/Dockerfile.production index 7381f74..0855297 100644 --- a/Dockerfile.production +++ b/Dockerfile.production | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | # Build the needed css files in an intermediate container | ||
| 2 | FROM node:14-buster AS static_web_assets_build | ||
| 3 | WORKDIR /var/www/mat2-web | ||
| 4 | COPY . /var/www/mat2-web | ||
| 5 | RUN npm install \ | ||
| 6 | && npm install --global postcss \ | ||
| 7 | && npm run build:css | ||
| 1 | # https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile | 8 | # https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile |
| 2 | |||
| 3 | From debian:buster-slim | 9 | From debian:buster-slim |
| 4 | 10 | ||
| 5 | LABEL maintainer="Mat-Web Co-Maintainer <jan.friedli@immerda.ch>" | 11 | LABEL maintainer="Mat-Web Co-Maintainer <jan.friedli@immerda.ch>" |
| @@ -7,6 +13,7 @@ LABEL maintainer="Mat-Web Co-Maintainer <jan.friedli@immerda.ch>" | |||
| 7 | WORKDIR /var/www/mat2-web | 13 | WORKDIR /var/www/mat2-web |
| 8 | 14 | ||
| 9 | COPY . /var/www/mat2-web | 15 | COPY . /var/www/mat2-web |
| 16 | COPY --from=static_web_assets_build /var/www/mat2-web/static/dist ./static/dist | ||
| 10 | 17 | ||
| 11 | ENV MAT2_WEB_DOWNLOAD_FOLDER /app/upload | 18 | ENV MAT2_WEB_DOWNLOAD_FOLDER /app/upload |
| 12 | 19 | ||
| @@ -38,6 +45,9 @@ RUN set -x \ | |||
| 38 | && mkdir -p /var/cache/nginx \ | 45 | && mkdir -p /var/cache/nginx \ |
| 39 | && chown -R 101:0 /var/cache/nginx \ | 46 | && chown -R 101:0 /var/cache/nginx \ |
| 40 | && chmod -R g+w /var/cache/nginx \ | 47 | && chmod -R g+w /var/cache/nginx \ |
| 48 | && mkdir -p /var/www/mat2-web/static/.webassets-cache \ | ||
| 49 | && chown -R 101:0 /var/www/mat2-web/static/.webassets-cache \ | ||
| 50 | && chmod -R g+w /var/www/mat2-web/static/.webassets-cache \ | ||
| 41 | && ln -sf /dev/stdout /var/log/nginx/access.log \ | 51 | && ln -sf /dev/stdout /var/log/nginx/access.log \ |
| 42 | && ln -sf /dev/stderr /var/log/nginx/error.log \ | 52 | && ln -sf /dev/stderr /var/log/nginx/error.log \ |
| 43 | && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ | 53 | && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ |
| @@ -23,7 +23,7 @@ def create_app(test_config=None): | |||
| 23 | 23 | ||
| 24 | # Non JS Frontend | 24 | # Non JS Frontend |
| 25 | assets = Environment(app) | 25 | assets = Environment(app) |
| 26 | css = Bundle("src/main.css", output="dist/main.css", filters="postcss") | 26 | css = Bundle("src/main.css", output="dist/main.css") |
| 27 | assets.register("css", css) | 27 | assets.register("css", css) |
| 28 | css.build() | 28 | css.build() |
| 29 | app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore | 29 | app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore |
