-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add config for running electric behind proxy in production
- Loading branch information
1 parent
587e9cf
commit f100524
Showing
12 changed files
with
227 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) Humanitarian OpenStreetMap Team | ||
# | ||
# This file is part of FMTM. | ||
# | ||
# FMTM is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# FMTM is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>. | ||
# | ||
|
||
server { | ||
listen 80; | ||
server_name ${FMTM_SYNC_DOMAIN}; | ||
|
||
location /.well-known/acme-challenge/ { | ||
root /var/www/certbot; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (c) Humanitarian OpenStreetMap Team | ||
# | ||
# This file is part of FMTM. | ||
# | ||
# FMTM is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# FMTM is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>. | ||
# | ||
|
||
upstream sync { | ||
server electric:3000 max_fails=1 fail_timeout=2s; | ||
keepalive 32; | ||
} | ||
|
||
server { | ||
# Default handler for port 80 | ||
listen 80; | ||
server_name sync.fmtm.localhost; | ||
|
||
# Max upload size 10MB | ||
client_max_body_size 10M; | ||
|
||
location / { | ||
# Max time to initiate connection with electric | ||
proxy_connect_timeout 10s; | ||
# Max time for a backend response to return | ||
proxy_read_timeout 20s; | ||
# Max time to send request to backend, i.e. upload | ||
proxy_send_timeout 20s; | ||
|
||
# Requests headers | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $http_host; | ||
proxy_set_header X-Forwarded-Server $http_host; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
|
||
# Disable buffer to temp files, tweak buffer for memory | ||
proxy_max_temp_file_size 0; | ||
proxy_buffer_size 64k; | ||
proxy_buffers 8 64k; | ||
proxy_busy_buffers_size 64k; | ||
|
||
proxy_pass http://sync; | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright (c) Humanitarian OpenStreetMap Team | ||
# | ||
# This file is part of FMTM. | ||
# | ||
# FMTM is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# FMTM is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>. | ||
# | ||
|
||
upstream sync { | ||
server electric:3000 max_fails=1 fail_timeout=2s; | ||
keepalive 32; | ||
} | ||
|
||
server { | ||
# Default handler for port 80 | ||
listen 80; | ||
server_name ${FMTM_SYNC_DOMAIN}; | ||
return 301 https://$host$request_uri; | ||
} | ||
|
||
server { | ||
# Default handler for port 443 | ||
listen 443 ssl reuseport; | ||
server_name ${FMTM_SYNC_DOMAIN}; | ||
|
||
ssl_certificate /etc/letsencrypt/live/${FMTM_DOMAIN}/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/${FMTM_DOMAIN}/privkey.pem; | ||
include /etc/nginx/options-ssl-nginx.conf; | ||
include /etc/nginx/options-security.conf; | ||
|
||
# Max upload size 1GB | ||
client_max_body_size 1G; | ||
|
||
# Response headers (Access-Control-Allow-Origin set by FastAPI, not required) | ||
add_header 'Content-Security-Policy' 'upgrade-insecure-requests'; | ||
# For opentelemetry | ||
add_header 'Access-Control-Allow-Headers' 'traceparent,tracestate'; | ||
|
||
location / { | ||
# Max time to initiate connection with electric | ||
proxy_connect_timeout 10s; | ||
# Max time for a backend response to return | ||
proxy_read_timeout 20s; | ||
# Max time to send request to backend, i.e. upload | ||
proxy_send_timeout 20s; | ||
|
||
# Requests headers | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $http_host; | ||
proxy_set_header X-Forwarded-Server $http_host; | ||
proxy_set_header X-Forwarded-Port $server_port; | ||
|
||
# Disable buffer to temp files, tweak buffer for memory | ||
proxy_max_temp_file_size 0; | ||
proxy_buffer_size 64k; | ||
proxy_buffers 8 64k; | ||
proxy_busy_buffers_size 64k; | ||
|
||
proxy_pass http://sync; | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
FROM docker.io/node:20 as base | ||
Check warning on line 1 in src/Dockerfile.ui.prod GitHub Actions / frontend-build / build-imageThe 'as' keyword should match the case of the 'from' keyword
|
||
ARG NODE_ENV | ||
ARG VITE_API_URL | ||
ARG VITE_SYNC_URL | ||
ENV VITE_API_URL=${VITE_API_URL} \ | ||
Check warning on line 5 in src/Dockerfile.ui.prod GitHub Actions / frontend-build / build-imageVariables should be defined before their use
|
||
VITE_SYNC_URL=${VITE_SYNC_URL} \ | ||
NODE_ENV=${NODE_ENV} \ | ||
PNPM_HOME="/pnpm" \ | ||
PATH="$PNPM_HOME:$PATH" | ||
|
@@ -27,11 +29,13 @@ FROM docker.io/rclone/rclone:1 as prod | |
ARG APP_VERSION | ||
ARG COMMIT_REF | ||
ARG VITE_API_URL | ||
ARG VITE_SYNC_URL | ||
LABEL org.hotosm.fmtm.app-name="frontend" \ | ||
org.hotosm.fmtm.app-version="${APP_VERSION}" \ | ||
org.hotosm.fmtm.git-commit-ref="${COMMIT_REF:-none}" \ | ||
org.hotosm.fmtm.maintainer="[email protected]" \ | ||
org.hotosm.fmtm.api-url="${VITE_API_URL}" | ||
org.hotosm.fmtm.api-url="${VITE_API_URL}" \ | ||
org.hotosm.fmtm.sync-url="${VITE_SYNC_URL}" | ||
VOLUME /frontend | ||
COPY container-entrypoint.sh / | ||
RUN chmod +x /container-entrypoint.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters