2
0
mirror of https://github.com/offen/website.git synced 2024-11-22 17:10:29 +01:00

use go app to serve static assets

This commit is contained in:
Frederik Ring 2019-10-04 18:51:24 +02:00
parent b8d1b66e5c
commit 522231c6c6
4 changed files with 14 additions and 50 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
.vscode .vscode
.serverless .serverless
node_modules/ node_modules/
# mkcert certificates public/
*.pem *.pem
venv/ venv/

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,21 @@ 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;
} }
error_page 404 /404.html; error_page 404 /404.html;

View File

@ -22,6 +22,7 @@ services:
volumes: volumes:
- .:/offen - .:/offen
- ./bootstrap.yml:/offen/server/bootstrap.yml - ./bootstrap.yml:/offen/server/bootstrap.yml
- ./public:/offen/server/public
- serverdeps:/go/pkg/mod - serverdeps:/go/pkg/mod
environment: environment:
POSTGRES_CONNECTION_STRING: postgres://postgres:develop@server_database:5432/postgres?sslmode=disable POSTGRES_CONNECTION_STRING: postgres://postgres:develop@server_database:5432/postgres?sslmode=disable