|
|
|
FROM postgres:latest |
|
|
|
|
|
ENV POSTGRES_USER=myuser \ |
|
POSTGRES_PASSWORD=mypassword \ |
|
POSTGRES_DB=mydatabase \ |
|
VIRTUAL_ENV=/opt/venv \ |
|
PATH="$VIRTUAL_ENV/bin:$PATH" |
|
|
|
|
|
USER root |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
python3 \ |
|
python3-pip \ |
|
python3-venv \ |
|
curl \ |
|
gosu \ |
|
--no-install-recommends && \ |
|
apt-get clean && \ |
|
rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN usermod -u 1000 postgres && groupmod -g 1000 postgres |
|
|
|
|
|
RUN chown -R postgres:postgres /var/lib/postgresql && \ |
|
chown -R postgres:postgres /var/run/postgresql |
|
|
|
|
|
RUN python3 -m venv $VIRTUAL_ENV && \ |
|
$VIRTUAL_ENV/bin/pip install --upgrade pip && \ |
|
$VIRTUAL_ENV/bin/pip install Flask psycopg2-binary |
|
|
|
|
|
COPY app.py /app/app.py |
|
COPY run.sh /app/run.sh |
|
|
|
|
|
RUN chmod +x /app/run.sh |
|
|
|
|
|
USER postgres |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
CMD ["./run.sh"] |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ |
|
CMD curl -f http://localhost:7860/ || exit 1 |
|
|