Skip to content

Commit 7612f8b

Browse files
committed
PROXY and HTTPS settings via env vars added
1 parent 5a6a7f1 commit 7612f8b

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.vscode
22
.DS_Store
3-
.env
3+
.env
4+
5+
# Certificates
6+
certs/

docker-compose.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3"
33
services:
44
opencloning:
55
build: .
6-
image: manulera/opencloning:prod
6+
image: manulera/opencloning:local
77
ports:
88
- "8000:8000"
99

@@ -24,6 +24,23 @@ services:
2424
# - BACKEND_URL=/opencloning/
2525
# Set this if you want to use plannotate
2626
- PLANNOTATE_URL=http://plannotate:8000
27+
# Set this if you want to use a proxy for the external requests made by the backend
28+
# (example is using mitmproxy locally on port 8080)
29+
- PROXY_URL=http://host.docker.internal:8080
30+
# Set this if you want to use a cert file for the proxy (e.g. when testing locally using mitmproxy and USE_HTTPS=true)
31+
# This file should be mounted. The path is absolute to the container.
32+
- PROXY_CERT_FILE=/certs/proxy.pem
33+
# Set to true if you are using HTTPS, you will have to provide cert files (see volumes section)
34+
- USE_HTTPS=true
35+
36+
volumes:
37+
- type: bind
38+
# Path to your local cert files
39+
source: ./certs
40+
# They will be mounted as read only at /certs in the container
41+
target: /certs
42+
read_only: true
43+
2744

2845
plannotate:
2946
image: manulera/plannotate-api

docker_entrypoint.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,15 @@ echo ""
1111
echo "------------------------------------"
1212
cd ..
1313

14-
# Only add --root-path if ROOT_PATH is not empty, otherwise uvicorn will throw an error
15-
uvicorn opencloning.main:app --host 0.0.0.0 --port 8000 ${ROOT_PATH:+--root-path ${ROOT_PATH}}
14+
15+
if [ "$USE_HTTPS" = "true" ]; then
16+
echo "Using HTTPS"
17+
if [ ! -f "/certs/key.pem" ] || [ ! -f "/certs/cert.pem" ] || [ ! -r "/certs/key.pem" ] || [ ! -r "/certs/cert.pem" ]; then
18+
echo "Error: TLS certificate files /certs/key.pem and /certs/cert.pem must both exist and be readable"
19+
exit 1
20+
fi
21+
uvicorn opencloning.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile /certs/key.pem --ssl-certfile /certs/cert.pem ${ROOT_PATH:+--root-path ${ROOT_PATH}}
22+
else
23+
echo "Using HTTP"
24+
uvicorn opencloning.main:app --host 0.0.0.0 --port 8000 ${ROOT_PATH:+--root-path ${ROOT_PATH}}
25+
fi

0 commit comments

Comments
 (0)