Skip to content

Commit

Permalink
dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Aug 23, 2021
1 parent 67a9589 commit 9190a6c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
13 changes: 7 additions & 6 deletions vwsfriend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Here is the build image
FROM python:3.8.0-slim as builder
RUN apt-get update \
&& apt-get install gcc -y \
&& apt-get install gcc libpq-dev python-dev -y \
&& apt-get clean
COPY . vwsfriend
RUN pip install --upgrade pip
RUN pip install --user vwsfriend
RUN python -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install vwsfriend

FROM python:3.9.6-slim-buster

Expand All @@ -15,8 +16,8 @@ ENV WECONNECT_INTERVAL=
ENV ADDITIONAL_PARAMETERS=
ENV DATABASE_URL=

COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN mkdir -p /config

CMD vwsfriend --username ${WECONNECT_USER} --password ${WECONNECT_PASSWORD} --interval ${WECONNECT_INTERVAL} --database-url ${DATABASE_URL} --config-dir /config ${ADDITIONAL_PARAMETERS}
48 changes: 30 additions & 18 deletions vwsfriend/Dockerfile-edge
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
FROM python:3.9.5-alpine
# Here is the build image
FROM ubuntu:20.04 as builder

ENV DEBIAN_FRONTEND="noninteractive"
ENV TZ="Etc/UTC"

RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY . vwsfriend
RUN python3.9 -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR ./vwsfriend/
RUN pip3 install --no-cache-dir wheel
RUN pip3 install --no-cache-dir -r requirements.txt
RUN pip3 install --no-cache-dir .

#RUN python setup.py install

FROM ubuntu:20.04 AS runner-image

ENV WECONNECT_USER=
ENV WECONNECT_PASSWORD=
ENV WECONNECT_INTERVAL=
ENV ADDITIONAL_PARAMETERS=
ENV DATABASE_URL=

COPY . vwsfriend
RUN apk add --no-cache --virtual .build-deps rust build-base gcc libc-dev libffi-dev musl-dev python3-dev libffi-dev openssl-dev cargo postgresql-dev && \
apk --no-cache add libpq && \
apk --no-cache add jpeg-dev \
zlib-dev \
freetype-dev \
lcms2-dev \
openjpeg-dev \
tiff-dev \
tk-dev \
tcl-dev
RUN --mount=type=cache,target=/root/.cache \
pip install -r ./vwsfriend/requirements.txt && \
pip install -r ./vwsfriend/setup_requirements.txt && \
pip install -r ./vwsfriend/test_requirements.txt && \
pip install ./vwsfriend/
RUN apk del .build-deps
RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3-venv && \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=builder /opt/venv /opt/venv
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN mkdir -p /config

# make sure all messages always reach console
ENV PYTHONUNBUFFERED=1

CMD vwsfriend --username ${WECONNECT_USER} --password ${WECONNECT_PASSWORD} --interval ${WECONNECT_INTERVAL} --database-url ${DATABASE_URL} --config-dir /config ${ADDITIONAL_PARAMETERS}

0 comments on commit 9190a6c

Please sign in to comment.