mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
Fix #3 add dockerfile
This commit is contained in:
82
docker/image/Dockerfile
Normal file
82
docker/image/Dockerfile
Normal 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
|
||||
Reference in New Issue
Block a user