Fix #3 add dockerfile

This commit is contained in:
sebthom
2022-01-24 06:25:12 +01:00
parent ba72989a85
commit cc9aaf9a4b
7 changed files with 240 additions and 2 deletions

82
docker/image/Dockerfile Normal file
View File

@@ -0,0 +1,82 @@
#
# Copyright (C) 2022 Sebastian Thomschke and contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
#
######################
# runtime image base
######################
FROM python:3-slim as runtime-base-image
LABEL maintainer="Sebastian Thomschke"
ARG DEBIAN_FRONTEND=noninteractive
ARG LC_ALL=C
RUN set -eu \
#
&& apt-get update -y \
&& echo "#################################################" \
&& echo "Install Chromium + Driver..." \
&& echo "#################################################" \
&& apt-get install --no-install-recommends -y chromium chromium-driver \
#
&& rm -rf \
/var/cache/{apt,debconf} \
/var/lib/apt/lists/* \
/var/log/{apt,alternatives.log,bootstrap.log,dpkg.log} \
/tmp/* /var/tmp/*
######################
# build image
######################
# https://hub.docker.com/_/python?tab=tags&name=3-slim
FROM python:3-slim AS build-image
RUN apt-get update \
&& apt-get install --no-install-recommends -y git \
&& python -m pip install --upgrade pip
COPY kleinanzeigen_bot /opt/app/kleinanzeigen_bot
COPY .git /opt/app/.git
COPY *.py *.txt *.toml /opt/app/
RUN cd /opt/app \
&& ls -la . \
&& pip install --user . \
# generates version.py
&& python setup.py --version
######################
# final image
######################
FROM runtime-base-image
COPY --from=build-image /root/.local /root/.local
ARG BUILD_DATE
ARG GIT_COMMIT_HASH
ARG GIT_COMMIT_DATE
ARG GIT_REPO_URL
LABEL \
org.label-schema.schema-version="1.0" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$GIT_COMMIT_HASH \
org.label-schema.vcs-url=$GIT_REPO_URL
# https://stackoverflow.com/a/59812588/5116073
ENV PYTHONUNBUFFERED=1
ENV DISPLAY=0:0
ENTRYPOINT ["/bin/bash", "/opt/run.sh"]
ENV \
INIT_SH_FILE='' \
CONFIG_FILE=/mnt/data/config.yaml
COPY docker/image/run.sh /opt/run.sh
VOLUME /mnt/data