-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (48 loc) · 1.92 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# While optional this tells the Docker builder of the version
# syntax=docker/dockerfile:1
#
ARG BASE_IMAGE=24.04
# This Dockerfile uses a multi stage build to slim down the image
# https://docs.docker.com/develop/develop-images/multistage-build/
#
# Portion of this is adapted from
# https://bit.ly/3Vw9B2m
#
# Base image for Python applications
# This image is particularly for a web server using uvicorn
FROM --platform=linux/amd64 ubuntu:${BASE_IMAGE} as requirements-stage
# Update the based image to latest versions of packages
# python 3.10 seems to want python3-tk installed
RUN apt update \
&& apt -y upgrade \
&& apt install -y --no-install-recommends gcc python3-dev \
python3-pip build-essential libpq-dev python3-tk \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Work in the temporary directory for the build phase
WORKDIR /tmp
# requirements.txt is used to install the python packages
COPY requirements.txt requirements.txt
# Copy the production Taskfile so it ends up on the container
COPY Taskfile.prod.yml Taskfile.yml
### Stage 2
FROM ubuntu:${BASE_IMAGE}
# Update the based image to latest versions of packages
# python 3.10 seems to want python3-tk installed
RUN apt update \
&& apt -y upgrade \
&& apt install -y --no-install-recommends libpq-dev \
python3-tk python3-pip postgresql-client curl \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Work in the temporary directory for the build phase
WORKDIR /opt
COPY --from=requirements-stage /tmp/Taskfile.yml Taskfile.yml
COPY --from=requirements-stage /tmp/requirements.txt requirements.txt
# Install python package we need
RUN pip install --no-cache-dir --upgrade -r requirements.txt
CMD ["bash"]
# Labels are used to identify the image
LABEL org.opencontainers.image.source="https://github.com/anomaly/${PROJ_NAME}"
LABEL org.opencontainers.image.description="Service node for Anomaly apps"
LABEL org.opencontainers.image.licenses="MIT"