Skip to content

Commit

Permalink
Revamp Dockerfile
Browse files Browse the repository at this point in the history
The existing base image seems to be abandoned and are not seeing
updates anymore. This isn't sustainable in the long run and a new
base images is implemented. The container is now based on a
condaforge image which allows us to use the conda environment used
in development.
  • Loading branch information
kbevers committed Nov 18, 2022
1 parent 30b1ac1 commit 219c378
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: docker build --tag webproj .
- run: 'docker run -d -p 0.0.0.0:5000:80 --name restapi webproj'
- run: 'docker run -d -p 80:80 --name restapi webproj'
- run: docker ps
- run: sudo apt-get update

Expand All @@ -28,9 +28,8 @@ jobs:
- name: Pytest
run: pytest --cov

- run: >-
docker exec restapi curl -s
localhost/v1.0/trans/EPSG:4258/DK:S34S/55.0,12.0 > S34S.out
- run: curl -s localhost/v1.0/trans/EPSG:4258/DK:S34S/55.0,12.0 > S34S.out

- run: cat S34S.out
- run: diff test_s34s.out S34S.out

Expand Down
38 changes: 17 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# See https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker
# for notes on how to use this particular Docker image.
#
# In summary: Make sure that a /app/main.py file with a FastAPI-object called
# 'app' is present and everything should run smoothly with all the bells and
# whistles of a properly configured HTTP server

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
FROM condaforge/miniforge3

# We store PROJ ressources in $WEBPROJ_LIB
ENV WEBPROJ_LIB /proj
RUN mkdir $WEBPROJ_LIB

RUN mkdir /proj

# Copy necessary files. Tests and README are needed by setup.py
COPY /webproj /webproj/webproj
COPY /tests /webproj/tests
COPY /app /webproj/app
COPY /tests /webproj/tests
COPY /setup.py /webproj/setup.py
COPY /environment.yaml /webproj/environment.yaml
COPY /README.md /webproj/README.md
COPY /app/main.py /app/main.py

WORKDIR /webproj

# Running upgrade for security
RUN apt update -y && apt upgrade -y
RUN apt-get update -y && apt-get upgrade -y

# Setup Python environment
RUN pip install --upgrade pip
RUN pip install pyproj
RUN pip install fastapi
RUN pip install unicorn
RUN pip install httpx
RUN pip install /webproj
# Set up virtual environment
RUN conda env create -f environment.yaml
RUN conda run -n webproj python -m pip install --no-deps .

# Sync PROJ-data files
RUN pyproj sync --source-id dk_sdfe
RUN conda run -n webproj pyproj sync --source-id dk_sdfe --target-dir $WEBPROJ_LIB

CMD ["conda", "run", "-n", "webproj", "uvicorn", "--proxy-headers", "app.main:app", "--host", "0.0.0.0", "--port", "80"]

EXPOSE 80

0 comments on commit 219c378

Please sign in to comment.