Skip to content

Commit

Permalink
[#50] Implement initial nginx settings
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Sep 9, 2024
1 parent 631f71e commit bc70fce
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR /app
# will be cached unless changes to one of those two files
# are made.
COPY package.json package-lock.json ./
RUN npm install --legacy-peer-deps
RUN npm install

# Copy the main application
COPY ./ /app/
Expand All @@ -33,12 +33,12 @@ COPY --from=build /app/dist /var/www
COPY ./public /var/www/public

# Copy our custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf.template
COPY deploy/.docker/nginx.conf /etc/nginx/nginx.conf.template

# Expose port 80 to the Docker host, so we can access it
# from the outside.
EXPOSE 80

COPY docker-entrypoint.sh /
COPY deploy/.docker/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion bin/spe.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for %%A in (%*) do (
)
)
)
cd %PROJECT_DIR%
cd %PROJECT_DIR%/deploy
echo starting s-pipes-editor-ui with scripts %CUSTOM_SCRIPT_PATHS%
docker-compose --env-file=.env.custom-script-paths up
:eof
Expand Down
3 changes: 1 addition & 2 deletions bin/spe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ done




cd $PROJECT_DIR
cd $PROJECT_DIR/deploy
CUSTOM_SCRIPT_PATHS="$CUSTOM_SCRIPT_PATHS" docker-compose --env-file=.env.custom-script-paths up
cd

File renamed without changes.
9 changes: 1 addition & 8 deletions nginx.conf → deploy/.docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@
try_files $uri =404;
}

location /rest/ {
proxy_pass ${SERVICE_URL}/og_spipes/rest/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

}
}
1 change: 1 addition & 0 deletions deploy/.env.custom-script-paths
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#SHARED_ROOT=/host_mnt
78 changes: 78 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: "3.9"

services:
nginx:
image: nginx:latest
ports:
- "1235:80"
container_name: "nginx_main"
restart: always
depends_on:
- s-pipes-engine
- s-pipes-editor-rest
- db-server
- s-pipes-editor-ui
environment:
NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx
APP_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}"
SERVICE_URL: "${SPIPES_EDITOR_REST:-http://s-pipes-editor-rest:18115}"
volumes:
- ./nginx/nginx.conf:/etc/nginx/templates/nginx.conf.template:ro
- ./nginx/error.html:/usr/share/nginx/html/error.html:ro

s-pipes-editor-ui:
image: "ghcr.io/kbss-cvut/s-pipes-editor-ui/s-pipes-editor-ui:latest"
expose:
- "80"
depends_on:
- s-pipes-editor-rest
environment:
SERVICE_URL: "${SPIPES_EDITOR_REST:-http://s-pipes-editor-rest:18115}"

s-pipes-editor-rest:
# <<: *s-pipes-editor-rest-dev-port
image: "ghcr.io/kbss-cvut/s-pipes-editor/s-pipes-editor:latest"
expose:
- "18115"
depends_on:
- s-pipes-engine
- db-server
environment:
SCRIPTPATHS: "${SCRIPTPATHS:-${PWD}/../../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../../s-pipes/doc/examples}}"
SCRIPTRULES: "${SCRIPTRULES:-${PWD}/../../s-pipes-editor/src/main/resources/rules}"
ENGINEURL: "${SPIPES_ENGINE:-http://s-pipes-engine:8080/s-pipes}/"
RDF4J_REPOSITORYURL: "${RDF4J_SERVER_URL:-http://db-server:7200}/repositories"
RDF4J_REPOSITORYNAME: "${RDF4J_REPOSITORYNAME:-s-pipes-hello-world}"
RDF4J_PCONFIGURL: "${RDF4J_PCONFIGURL:-./s-pipes-engine/config.ttl}"
volumes:
- /tmp:/tmp
- ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home}
# - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/

s-pipes-engine:
image: "ghcr.io/kbss-cvut/s-pipes/s-pipes-engine:latest"
# container_name: s-pipes-engine
expose:
- "8080"
depends_on:
- db-server
environment:
CONTEXTS_SCRIPTPATHS: "${SCRIPTPATHS:-${PWD}/../../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../../s-pipes/doc/examples}}"
volumes:
- /tmp:/tmp
- ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home}
# - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/

db-server:
build:
context: ./db-server
ports:
- "7200:7200"
volumes:
- ./db-server/init-config:/repo-config:ro
- db-server:/opt/graphdb/home

volumes:
data:
logs:
db-server:
35 changes: 35 additions & 0 deletions deploy/nginx/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- Record manager Nginx reverse proxy-->
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title><!--# echo var="status" default="" --> | Record manager</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--# if expr="$status = 502" -->
<meta http-equiv="refresh" content="2" />
<!--# endif -->
</head>
<style type="text/css">
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
color: #fff;
height: 100vh;
margin: 0;
background: #263238 linear-gradient(5deg, #057fa5 0%, #263238 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
<body>
<!--# if expr="$status = 502" -->
<h1>The application is currently being updated</h1>
<p>You will be redirected to the new version in a few seconds.</p>
<p>If you see this message for more than a minute, something has gone wrong.</p>
<!--# else -->
<h1>Sorry, something went wrong.</h1>
<p><!--# echo var="status" default="" --></p>
<!--# endif -->
</body>
</html>
96 changes: 96 additions & 0 deletions deploy/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
worker_processes 1;

events
{
worker_connections 1024;
}

http
{

client_max_body_size 100M;

include mime.types;
default_type application/octet-stream;

map $status $status_text
{
400 'Bad Request';
401 'Unauthorized';
403 'Forbidden';
404 'Not Found';
405 'Method Not Allowed';
406 'Not Acceptable';
413 'Payload Too Large';
414 'URI Too Long';
431 'Request Header Fields Too Large';
500 'Internal Server Error';
501 'Not Implemented';
502 'Bad Gateway';
503 'Service Unavailable';
504 'Gateway Timeout';
}

server
{
listen 80;
server_name localhost;
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
415 416 417 418 421 422 423 424 426 428 429 431 451 500 501 502 503
504 505 506 507 508 510 511 /error.html;

location = /error.html {

ssi on;
internal;
root /usr/share/nginx/html;
}

location / {
proxy_pass http://s-pipes-editor-ui;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /rest {
return 302 ${APP_ORIGIN}/rest/;
}

location /rest/ {
proxy_pass ${SERVICE_URL}/og_spipes/rest/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location = /services/db-server
{
return 302 ${APP_ORIGIN}/services/db-server/;
}

location = /services/db-server/
{
proxy_pass http://db-server:7200/;
}

location = /services/s-pipes {
return 302 ${APP_ORIGIN}/services/s-pipes/;
}

location = /services/s-pipes/
{
proxy_pass http://s-pipes-engine:8080/;
}

location = /health-check
{
return 200;
access_log off;
}

}
}

0 comments on commit bc70fce

Please sign in to comment.