2
0
mirror of https://github.com/offen/website.git synced 2024-11-25 18:20:28 +01:00

Merge pull request #154 from offen/gin-framework

Build server and all assets into single binary
This commit is contained in:
Frederik Ring 2019-10-07 20:46:35 +02:00 committed by GitHub
commit ded93b59d5
6 changed files with 32 additions and 54 deletions

11
.gitignore vendored
View File

@ -1,9 +1,12 @@
.vscode .vscode
.serverless
node_modules/
# mkcert certificates
*.pem *.pem
venv/
bootstrap-alpha.yml bootstrap-alpha.yml
Dockerrun.aws.json Dockerrun.aws.json
node_modules/
dist/
*.log
bin/
statik.go

View File

@ -1,45 +1,3 @@
FROM node:10 as auditorium
COPY ./auditorium/package.json ./auditorium/package-lock.json /code/deps/
COPY ./packages /code/packages
WORKDIR /code/deps
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN npm ci
COPY ./auditorium /code/auditorium
COPY ./banner.txt /code/banner.txt
WORKDIR /code/auditorium
RUN cp -a /code/deps/node_modules /code/auditorium/
ENV NODE_ENV production
RUN npm run build
FROM node:10 as script
COPY ./script/package.json ./script/package-lock.json /code/deps/
COPY ./packages /code/packages
WORKDIR /code/deps
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN npm ci
COPY ./script /code/script
COPY ./banner.txt /code/banner.txt
WORKDIR /code/script
RUN cp -a /code/deps/node_modules /code/script/
ENV NODE_ENV production
RUN npm run build
FROM node:10 as vault
COPY ./vault/package.json ./vault/package-lock.json /code/deps/
COPY ./packages /code/packages
WORKDIR /code/deps
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN npm ci
COPY ./vault /code/vault
COPY ./banner.txt /code/banner.txt
WORKDIR /code/vault
RUN cp -a /code/deps/node_modules /code/vault/
ENV NODE_ENV production
RUN npm run build
FROM nikolaik/python-nodejs:python3.7-nodejs10 as homepage FROM nikolaik/python-nodejs:python3.7-nodejs10 as homepage
ARG siteurl ARG siteurl
@ -64,9 +22,6 @@ ARG robots
ENV ROBOTS_FILE=$robots ENV ROBOTS_FILE=$robots
COPY --from=homepage /code/homepage/output /www/data COPY --from=homepage /code/homepage/output /www/data
COPY --from=script /code/script/dist /www/data
COPY --from=auditorium /code/auditorium/dist /www/data/auditorium
COPY --from=vault /code/vault/dist /www/data/vault
COPY ./build/proxy/$ROBOTS_FILE /www/data/robots.txt COPY ./build/proxy/$ROBOTS_FILE /www/data/robots.txt
COPY ./build/proxy/nginx.conf /etc/nginx/nginx.conf COPY ./build/proxy/nginx.conf /etc/nginx/nginx.conf

View File

@ -37,13 +37,30 @@ http {
location /api/ { location /api/ {
proxy_pass http://server; proxy_pass http://server;
proxy_redirect off; proxy_redirect off;
rewrite ^/api(.*)$ $1 break; }
proxy_hide_header Content-Type;
add_header Content-Type "application/json"; location /vault/ {
proxy_pass http://server;
proxy_redirect off;
} }
location /auditorium/ { location /auditorium/ {
try_files $uri $uri/ /auditorium/index.html; proxy_pass http://server;
proxy_redirect off;
}
location /script.js {
proxy_pass http://server;
proxy_redirect off;
}
location /healthz {
proxy_pass http://server;
proxy_redirect off;
}
location /favicon.ico {
root /www/data/theme/images;
} }
error_page 404 /404.html; error_page 404 /404.html;

View File

@ -34,6 +34,8 @@ services:
command: refresh run command: refresh run
links: links:
- server_database - server_database
ports:
- 8081:8080
server_database: server_database:
image: postgres:11.2 image: postgres:11.2

View File

@ -2,6 +2,7 @@ Title: Page not found | offen
description: offen is a free and open source analytics software for websites and web applications that allows respectful handling of data. description: offen is a free and open source analytics software for websites and web applications that allows respectful handling of data.
save_as: 404.html save_as: 404.html
href: /404.html href: /404.html
no_stats: true
![Page not Found](/theme/images/content-404.webp){:class="image-text-560-315"} ![Page not Found](/theme/images/content-404.webp){:class="image-text-560-315"}

View File

@ -22,7 +22,7 @@
{% assets filters="cssmin", output="css/style.min.css", "css/normalize.css", "css/fonts.css", "css/style.css" %} {% assets filters="cssmin", output="css/style.min.css", "css/normalize.css", "css/fonts.css", "css/style.css" %}
<link rel="stylesheet" href="/{{ ASSET_URL }}"> <link rel="stylesheet" href="/{{ ASSET_URL }}">
{% endassets %} {% endassets %}
{% if OFFEN_ACCOUNT_ID %} {% if OFFEN_ACCOUNT_ID and not page.no_stats %}
<script async src="/script.js" data-account-id="{{ OFFEN_ACCOUNT_ID }}"></script> <script async src="/script.js" data-account-id="{{ OFFEN_ACCOUNT_ID }}"></script>
{% endif %} {% endif %}
</head> </head>