Skip to content

Commit 6408eda

Browse files
committed
chore: port docker config from python lab
1 parent 296f65b commit 6408eda

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# While optional this tells the Docker builder of the version
2+
# syntax=docker/dockerfile:1
3+
4+
# Base image for Python applications
5+
# This image is particularly for a web server using uvicorn
6+
FROM python:3.10-slim-buster
7+
8+
ENV APP=labs
9+
10+
# Expose ports which is proxied via traefik
11+
EXPOSE 80
12+
13+
# Update the based image to latest versions of packages
14+
# python 3.10 seems to want python3-tk installed
15+
RUN apt-get update \
16+
&& apt-get -y upgrade \
17+
&& apt-get install -y --no-install-recommends gcc python3-dev build-essential libpq-dev python3-tk \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Copy the files in the src directory which is the app package
22+
# and the dependency matrix dedescribed by pyproject.toml
23+
WORKDIR /opt/lab_mock
24+
COPY ./src/. .
25+
26+
# Ask poetry to install all packages including the app
27+
# not in virtual machine as we are in a container
28+
# In prodduction add --no-dev to poetry installation
29+
RUN pip3 install --upgrade pip
30+
RUN pip3 install poetry
31+
RUN poetry config virtualenvs.create false
32+
RUN poetry install --no-root
33+
34+
# The app package will be located in /opt/appname so run
35+
# uvicorn at this level so it sees the package
36+
WORKDIR /opt/
37+
ENTRYPOINT ["uvicorn", "lab_mock:app", "--host=0.0.0.0", "--port=80", "--reload"]
38+
39+
# There can only be one CMD argument
40+
CMD []

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# The aim of this docker compose file is to provide a good known
2+
# way to build your docker-compose file for Anomaly projects
3+
#
4+
# This file provides you a template for your development environment
5+
6+
# https://docs.docker.com/compose/compose-file/compose-versioning/
7+
version: "3.8"
8+
9+
volumes:
10+
lab_mock:
11+
12+
services:
13+
14+
# Mock application
15+
# - In development we read secrets from .env.development
16+
# - Provides a FastAPI based API that runs using uvicorn in development
17+
lab_mock:
18+
build:
19+
context: .
20+
dockerfile: Dockerfile
21+
env_file:
22+
- .env.development
23+
restart: unless-stopped
24+
ports:
25+
- "8000:80"
26+
volumes:
27+
- ./src/lab_mock:/opt/lab_mock

0 commit comments

Comments
 (0)