mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
build: add Docker functionality and documentation
This commit is contained in:
6
client/.dockerignore
Normal file
6
client/.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
node_modules/*
|
||||
package-lock.json
|
||||
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
**/.gitignore
|
31
client/Dockerfile
Normal file
31
client/Dockerfile
Normal file
@ -0,0 +1,31 @@
|
||||
FROM node:9 as builder
|
||||
WORKDIR /opt/app
|
||||
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . ./
|
||||
|
||||
ARG BUILD_INFO="docker-latest"
|
||||
ARG CLIENT_BUILD_ARGS=""
|
||||
RUN node build.js ${CLIENT_BUILD_ARGS}
|
||||
|
||||
RUN find public/ -type f -size +5k -print0 | xargs -0 -- gzip -6 -k
|
||||
|
||||
|
||||
FROM nginx:alpine
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN \
|
||||
# Create init file
|
||||
echo "#!/bin/sh" >> /init && \
|
||||
echo 'sed -i "s|__BACKEND__|${BACKEND_HOST}|" /etc/nginx/nginx.conf' \
|
||||
>> /init && \
|
||||
echo 'exec nginx -g "daemon off;"' >> /init && \
|
||||
chmod a+x /init
|
||||
|
||||
CMD ["/init"]
|
||||
VOLUME ["/data"]
|
||||
|
||||
COPY nginx.conf.docker /etc/nginx/nginx.conf
|
||||
COPY --from=builder /opt/app/public/ .
|
56
client/nginx.conf.docker
Normal file
56
client/nginx.conf.docker
Normal file
@ -0,0 +1,56 @@
|
||||
worker_processes 1;
|
||||
|
||||
error_log /dev/stderr warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr -> $request [$status] - '
|
||||
'referer: $http_referer $http_x_forwarded_for';
|
||||
access_log /dev/stdout main;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
client_max_body_size 100M;
|
||||
|
||||
upstream backend {
|
||||
server __BACKEND__:6666;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
location ~ ^/api$ {
|
||||
return 302 /api/;
|
||||
}
|
||||
|
||||
location ~ ^/api/(.*)$ {
|
||||
if ($request_uri ~* "/api/(.*)") {
|
||||
proxy_pass http://backend/$1;
|
||||
}
|
||||
gzip on;
|
||||
gzip_comp_level 3;
|
||||
gzip_min_length 20;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain application/json;
|
||||
}
|
||||
|
||||
location /data/ {
|
||||
rewrite ^/data/(.*) /$1 break;
|
||||
root /data;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /var/www;
|
||||
try_files $uri /index.htm;
|
||||
gzip_static on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user