Skip to content

Commit 11d92e6

Browse files
author
RM
committed
Docker inside Docker?
1 parent e5642d1 commit 11d92e6

2 files changed

Lines changed: 23 additions & 53 deletions

File tree

.github/workflows/deploy-chipnik-monitor-self-hosted.yml

Lines changed: 22 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111

1212
env:
1313
APP_DIR: chipnik_monitor
14-
PYTHON_VERSION: "3.11"
1514
SERVICE_PORT: "8080"
1615

1716
jobs:
@@ -25,66 +24,36 @@ jobs:
2524
- name: Checkout repository
2625
uses: actions/checkout@v4
2726

28-
- name: Set up Python
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: ${{ env.PYTHON_VERSION }}
32-
cache: "pip"
33-
cache-dependency-path: ${{ env.APP_DIR }}/requirements.txt
34-
35-
- name: Install dependencies
27+
- name: Build image
3628
working-directory: ${{ env.APP_DIR }}
3729
run: |
38-
python -m pip install --upgrade pip
39-
pip install -r requirements.txt
30+
docker build -t chipnik-monitor:latest .
4031
41-
- name: Stop existing service
42-
shell: bash
32+
- name: Stop previous container (if any)
4333
run: |
44-
if pgrep -f "uvicorn api:app" >/dev/null; then
45-
echo "Stopping existing Chipnik Monitor process"
46-
pkill -f "uvicorn api:app"
47-
sleep 5
48-
else
49-
echo "No existing Chipnik Monitor process found"
50-
fi
34+
docker rm -f chipnik-monitor || true
5135
52-
- name: Start service
36+
- name: Run container
5337
env:
5438
EARTHDATA_BEARER_TOKEN: ${{ secrets.EARTHDATA_BEARER_TOKEN }}
5539
MONGO_URI: ${{ secrets.MONGO_URI }}
5640
MONGO_DB: ${{ secrets.MONGO_DB }}
57-
DAYS_BACK_LIMIT: ${{ vars.DAYS_BACK_LIMIT }}
58-
working-directory: ${{ env.APP_DIR }}
59-
shell: bash
41+
DAYS_BACK_LIMIT: ${{ vars.DAYS_BACK_LIMIT || 2000 }}
42+
SERVICE_PORT: ${{ env.SERVICE_PORT }}
6043
run: |
61-
for var in EARTHDATA_BEARER_TOKEN MONGO_URI MONGO_DB; do
62-
if [[ -z "${!var}" ]]; then
63-
echo "::error::Environment variable $var must be provided via repository secrets."
64-
exit 1
65-
fi
66-
done
67-
68-
LOG_PATH="${HOME}/chipnik-monitor.log"
69-
echo "Starting Chipnik Monitor on port ${SERVICE_PORT}, logging to ${LOG_PATH}"
70-
71-
nohup env \
72-
EARTHDATA_BEARER_TOKEN="${EARTHDATA_BEARER_TOKEN}" \
73-
MONGO_URI="${MONGO_URI}" \
74-
MONGO_DB="${MONGO_DB}" \
75-
DAYS_BACK_LIMIT="${DAYS_BACK_LIMIT:-2000}" \
76-
uvicorn api:app --host 0.0.0.0 --port "${SERVICE_PORT}" \
77-
> "${LOG_PATH}" 2>&1 &
78-
79-
echo $! > "${HOME}/chipnik-monitor.pid"
80-
echo "Process started with PID $(cat "${HOME}/chipnik-monitor.pid")"
81-
82-
- name: Verify service
83-
shell: bash
44+
docker run -d --name chipnik-monitor \
45+
--restart=always \
46+
-p ${SERVICE_PORT}:${SERVICE_PORT} \
47+
-e EARTHDATA_BEARER_TOKEN \
48+
-e MONGO_URI \
49+
-e MONGO_DB \
50+
-e DAYS_BACK_LIMIT \
51+
chipnik-monitor:latest \
52+
uvicorn api:app --host 0.0.0.0 --port ${SERVICE_PORT}
53+
54+
- name: Health check
8455
run: |
85-
sleep 5
86-
if ! pgrep -f "uvicorn api:app" >/dev/null; then
87-
echo "::error::Chipnik Monitor service failed to start. Check logs at ${HOME}/chipnik-monitor.log"
88-
exit 1
89-
fi
90-
echo "Chipnik Monitor service is running"
56+
sleep 3
57+
docker ps --format '{{.Names}}' | grep -q '^chipnik-monitor$'
58+
curl -fsS http://127.0.0.1:${{ env.SERVICE_PORT }}/docs >/dev/null
59+
echo "Chipnik Monitor container is up"

chipnik_monitor/on-premise/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RUN apt-get update \
2121
libgdal-dev \
2222
proj-bin \
2323
libproj-dev \
24+
docker.io \
2425
&& rm -rf /var/lib/apt/lists/*
2526

2627
RUN curl -fsSL https://www.noip.com/download/linux/latest -o /tmp/noip-duc.tar.gz \

0 commit comments

Comments
 (0)