Skip to content

Commit ea3548b

Browse files
committed
chore: update Docker setup and configurations
- Adjust healthcheck intervals and retries in `compose.yml` - Update `Dockerfile` with new dependencies and cleanup - Add database initialization handling to entrypoint - Replace Flask static handling in `factory.py` - Remove deprecated files and align configuration files with latest standards
1 parent ba39325 commit ea3548b

File tree

11 files changed

+47
-296
lines changed

11 files changed

+47
-296
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ lemur/static/dist
99
node_modules
1010
bower_components
1111
.tmp
12+
migrations

Caddyfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
:80 {
2-
encode gzip zstd
32
handle /api/* {
43
reverse_proxy localhost:8000
54
}

Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RUN uv sync --frozen
3535

3636
RUN npm install \
3737
&& npm run build_static \
38+
&& node_modules/.bin/gulp package --urlContextPath="" \
3839
&& rm -rf node_modules bower_components .tmp
3940

4041

@@ -45,9 +46,14 @@ ENV PATH="/opt/lemur/.venv/bin:${PATH}" \
4546
PYTHONDONTWRITEBYTECODE=1
4647

4748
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends \
48-
curl \
49-
libldap-2.5-0 \
50-
make && \
49+
debian-keyring debian-archive-keyring apt-transport-https curl libldap-2.5-0 make gnupg && \
50+
rm -rf /var/lib/apt/lists/*
51+
52+
RUN curl -1sLf https://dl.cloudsmith.io/public/caddy/stable/gpg.key | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \
53+
curl -1sLf https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt | tee /etc/apt/sources.list.d/caddy-stable.list && \
54+
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg && \
55+
chmod o+r /etc/apt/sources.list.d/caddy-stable.list && \
56+
apt update && apt install caddy && \
5157
rm -rf /var/lib/apt/lists/*
5258

5359
# Create lemur user
@@ -63,8 +69,7 @@ RUN chmod +x /opt/lemur/entrypoint
6369
USER lemur
6470

6571
# Expose port
66-
EXPOSE 8000
72+
EXPOSE 80
6773

6874
# Default command
6975
ENTRYPOINT ["/opt/lemur/entrypoint"]
70-
CMD ["start"]

Dockerfile-src_old

Lines changed: 0 additions & 68 deletions
This file was deleted.

Dockerfile_old

Lines changed: 0 additions & 70 deletions
This file was deleted.

SETUP.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ make html
3333
The frontend is an AngularJS 1.x application that needs to be compiled:
3434

3535
```bash
36-
npm install # Install dependencies
37-
npm run build_static # Runs gulp build
36+
npm install # Install dependencies
37+
npm run build_static # Runs gulp build
38+
gulp package --urlContextPath="" # set correct path for proper URL generating to backend
3839
```
3940

4041
## Build with Docker

compose.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ services:
1212
- postgres_data:/var/lib/postgresql/data
1313
healthcheck:
1414
test: [ "CMD-SHELL", "pg_isready -U lemur" ]
15-
interval: 10s
15+
interval: 5s
1616
timeout: 5s
17-
retries: 5
17+
start_period: 5s
18+
retries: 3
1819

1920
# redis:
2021
# image: redis:8-alpine
@@ -27,19 +28,6 @@ services:
2728
# timeout: 5s
2829
# retries: 5
2930

30-
# caddy:
31-
# image: caddy:2-alpine
32-
# container_name: lemur-caddy
33-
# depends_on:
34-
# lemur:
35-
# condition: service_healthy
36-
# ports:
37-
# - "80:80"
38-
# - "443:443"
39-
# volumes:
40-
# - ./Caddyfile:/etc/caddy/Caddyfile:ro
41-
## - ./lemur/static/dist:/opt/lemur/lemur/static/dist:ro
42-
4331
lemur:
4432
build:
4533
context: .
@@ -52,14 +40,16 @@ services:
5240
LOG_FILE: "/opt/lemur/lemur.log"
5341
SQLALCHEMY_DATABASE_URI: "postgresql://lemur:lemur@postgres:5432/lemur"
5442
LEMUR_CONF: "/opt/lemur/lemur.conf.py"
43+
LEMUR_INIT: "1"
44+
LEMUR_PASSWORD: "lemur"
5545
ports:
56-
- "8000:8000"
46+
- "80:80"
5747
healthcheck:
5848
test: [ "CMD", "curl", "-f", "http://localhost:8000/api/1/healthcheck" ]
59-
interval: 15s
60-
timeout: 10s
49+
interval: 5s
50+
timeout: 5s
51+
start_period: 5s
6152
retries: 3
62-
start_period: 30s
6353

6454
volumes:
6555
postgres_data:

entrypoint

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
echo "[entrypoint] Starting Lemur container..."
5-
4+
echo "[supervisor] Starting Lemur container..."
65
install -Dm644 /opt/lemur/lemur.conf.py /home/lemur/.lemur/lemur.conf.py
76

8-
# Detect whether DB was already initialized
9-
#if [ ! -f "/opt/lemur/.db_initialized" ]; then
10-
# echo "[entrypoint] Initializing database..."
11-
#
12-
# lemur db create || true
13-
# lemur db init || true
14-
# lemur db migrate
15-
# lemur init -p password
16-
#
17-
# touch /opt/lemur/.db_initialized
18-
# echo "[entrypoint] DB initialization complete."
19-
#else
20-
# echo "[entrypoint] DB already initialized; skipping."
21-
#fi
7+
cd /opt/lemur
8+
9+
if [[ "$LEMUR_INIT" == "1" ]]; then
10+
echo "[supervisor] Running Lemur Bootstrap"
11+
.venv/bin/lemur db init
12+
.venv/bin/lemur db migrate
13+
.venv/bin/lemur init -p "$LEMUR_PASSWORD"
14+
fi
15+
16+
echo "[supervisor] Running database migrations..."
17+
.venv/bin/lemur db upgrade || {
18+
echo "[db] Migration failed; refusing to start app."
19+
exit 1
20+
}
21+
22+
echo "[supervisor] Starting Lemur server..."
23+
.venv/bin/lemur start -w 4 -b 0.0.0.0:8000 &
24+
LEMUR_PID=$!
25+
26+
trap 'echo "[supervisor] Caught stop signal"; kill "$LEMUR_PID" "$CADDY_PID" 2>/dev/null || true' SIGTERM SIGINT
2227

23-
# Interpret CMD
24-
case "$1" in
25-
start)
26-
echo "[entrypoint] Starting Lemur server..."
27-
exec lemur start -w 4 -b 0.0.0.0:8000
28-
;;
29-
migrate)
30-
echo "[entrypoint] Running migrations..."
31-
exec lemur db migrate
32-
;;
33-
*)
34-
echo "[entrypoint] Running custom command: $@"
35-
exec "$@"
36-
;;
37-
esac
28+
echo "[supervisor] Starting Caddy (foreground)..."
29+
exec caddy run --config /opt/lemur/Caddyfile

entrypoint_old

Lines changed: 0 additions & 59 deletions
This file was deleted.

lemur/factory.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,7 @@ def create_app(app_name=None, blueprints=None, config=None):
5454
if not app_name:
5555
app_name = __name__
5656

57-
app = Flask(app_name, static_folder='static/dist', static_url_path='')
58-
59-
@app.route('/')
60-
@app.route('/<path:path>')
61-
def index(path=None):
62-
if path and path.startswith('api/'):
63-
return "Not Found", 404
64-
return app.send_static_file('index.html')
57+
app = Flask(app_name)
6558

6659
ctx = get_current_context(silent=True)
6760

0 commit comments

Comments
 (0)