forked from sciapp/sampledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (39 loc) · 1.7 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM python:3.10-slim-bullseye
LABEL maintainer="[email protected]"
# Install required system packages
# GCC is required to build python dependencies on ARM architectures
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y gcc libpangocairo-1.0-0 gettext
# Switch to non-root user
RUN useradd -ms /bin/bash sampledb
USER sampledb
WORKDIR /home/sampledb
# Install required Python packages
COPY requirements.txt requirements.txt
RUN pip install --user --no-cache-dir --no-warn-script-location -r requirements.txt
# Clean up system packages that are no longer required
USER root
RUN apt-get remove -y gcc && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
USER sampledb
# Copy sampledb source code
COPY --chown=sampledb:sampledb sampledb sampledb
# By default, expect a normal postgres container to be linked
ENV SAMPLEDB_SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://postgres:@postgres:5432/postgres"
# Set default file storage path
ENV SAMPLEDB_FILE_STORAGE_PATH=/home/sampledb/files
# Set the path for pybabel
ENV SAMPLEDB_PYBABEL_PATH=/home/sampledb/.local/bin/pybabel
# Write Docker build arg SAMPLEDB_VERSION to environment to be read by sampledb/version.py.
ARG SAMPLEDB_VERSION
ENV SAMPLEDB_VERSION=$SAMPLEDB_VERSION
# Copy the SampleDB helper script
COPY ./docker-helper.sh /usr/local/bin/sampledb
# The entrypoint script will set the file permissions for a mounted files directory and then start SampleDB
COPY docker-entrypoint.sh docker-entrypoint.sh
USER root
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["run"]
HEALTHCHECK --interval=1m --timeout=3s --start-period=1m CMD curl -f -H "Host: $SAMPLEDB_SERVER_NAME" "http://localhost:8000$SAMPLEDB_SERVER_PATH/status/" || exit 1