feat: dockerfile and deployment scripts
This commit is contained in:
parent
2c99bcbb0a
commit
21a04124f2
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Basic DB healthcheck
|
||||||
|
COPY ./scripts/healthcheck.sh /app/healthcheck.sh
|
||||||
|
RUN chmod +x /app/healthcheck.sh
|
||||||
|
HEALTHCHECK --interval=120s --timeout=10s --start-period=5s --retries=3 CMD /app/healthcheck.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "main.py"]
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
23
scripts/deploy.sh
Executable file
23
scripts/deploy.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "[+] Starting the deployment script"
|
||||||
|
|
||||||
|
! command -v docker &> /dev/null && echo "[!] Docker could not be found, exiting..." && exit 1
|
||||||
|
|
||||||
|
# Building with '--no-cache' ensures a fresh build will always be used
|
||||||
|
echo -e "\n[+] Building the Docker image without caching..."
|
||||||
|
docker build --no-cache -t chainmapper .
|
||||||
|
|
||||||
|
[ ! -d "./data" ] && mkdir data && echo -e "\n[+] Created the default volume directory 'data'"
|
||||||
|
|
||||||
|
OLD_ID=$(docker ps -a -q -f name="chainmapper-prod")
|
||||||
|
|
||||||
|
if [ "$OLD_ID" ]
|
||||||
|
then
|
||||||
|
read -p "[?] Existing container found with id '$OLD_ID', do you want to remove it? " -n 1 -r
|
||||||
|
[[ "$REPLY" =~ ^[Yy]$ ]] || (echo "[!] Exiting..." && exit 0)
|
||||||
|
docker rm "$OLD_ID" &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n[+] Deploying the container with 'docker run' ('data' as the volume)..."
|
||||||
|
docker run -it -v ./data:/app/data --name chainmapper-prod -d chainmapper
|
9
scripts/healthcheck.sh
Normal file
9
scripts/healthcheck.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Included into the built image via its Dockerfile
|
||||||
|
|
||||||
|
if [ -s /app/chainmapper.sqlite3 ]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user