Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Docker image build #24

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 29 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
# gunicorn-flask

# requires this ubuntu version due to protobuf library update
FROM ubuntu:18.04
MAINTAINER Nils Nolde <nils@openrouteservice.org>
FROM ubuntu:18.04 AS builder

RUN apt-get update
RUN apt-get install -y locales git python3-venv

# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# oes/flask variables
ENV OES_LOGLEVEL INFO
ENV FLASK_APP manage
ENV FLASK_ENV production
ENV APP_SETTINGS openelevationservice.server.config.ProductionConfig
RUN apt-get -y install build-essential python3-dev python3-venv

# tzdata is being annoying otherwise
RUN /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata"
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN dpkg-reconfigure --frontend noninteractive tzdata

# Needs postgis installation locally for raster2pgsql
RUN apt-get install -y postgis

# Setup flask application
RUN mkdir -p /deploy/app

COPY openelevationservice /deploy/app/openelevationservice
COPY ops_settings_docker.sample.yml /deploy/app/openelevationservice/server/ops_settings.yml
COPY gunicorn_config.py /deploy/gunicorn_config.py
COPY manage.py /deploy/app/manage.py

COPY requirements.txt /deploy/app/requirements.txt

RUN python3 -m venv /oes_venv

RUN /bin/bash -c "source /oes_venv/bin/activate"

RUN /oes_venv/bin/pip3 install wheel
RUN /oes_venv/bin/pip3 install -r /deploy/app/requirements.txt

COPY openelevationservice /deploy/app/openelevationservice
COPY ops_settings_docker.yml /deploy/app/openelevationservice/server/ops_settings.yml
FROM ubuntu:18.04

COPY --from=builder /deploy /deploy
COPY --from=builder /oes_venv /oes_venv

RUN apt-get update \
&& /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install locales postgis postgresql-client python3-venv tzdata" \
&& ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& locale-gen en_US.UTF-8 \
&& apt-get -y --purge autoremove \
&& apt-get clean \
&& /bin/bash -c "source /oes_venv/bin/activate"

# Set the locale
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# oes/flask variables
ENV OES_LOGLEVEL INFO
ENV FLASK_APP manage
ENV FLASK_ENV production
ENV APP_SETTINGS openelevationservice.server.config.ProductionConfig

WORKDIR /deploy/app

EXPOSE 5000

# Start gunicorn
CMD ["/oes_venv/bin/gunicorn", "--config", "/deploy/gunicorn_config.py", "manage:app"]
CMD ["/oes_venv/bin/gunicorn", "--config", "/deploy/gunicorn_config.py", "manage:app"]