generated from app-sre/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
54 lines (43 loc) · 1.64 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
FROM quay.io/redhat-services-prod/app-sre-tenant/er-base-terraform-main/er-base-terraform-main:tf-1.6.6-py-3.12-v0.3.4-1@sha256:1579e58702182a02b55a0841254d188a6b99ff42c774279890567338c863a31b AS base
# keep in sync with pyproject.toml
LABEL konflux.additional-tags="0.4.3"
ENV TERRAFORM_MODULE_SRC_DIR="./terraform"
ENV \
# Use the virtual environment
PATH="${APP}/.venv/bin:${PATH}"
FROM base AS builder
COPY --from=ghcr.io/astral-sh/uv:0.6.14@sha256:3362a526af7eca2fcd8604e6a07e873fb6e4286d8837cb753503558ce1213664 /uv /bin/uv
# Python and UV related variables
ENV \
# compile bytecode for faster startup
UV_COMPILE_BYTECODE="true" \
# disable uv cache. it doesn't make sense in a container
UV_NO_CACHE=true \
UV_NO_PROGRESS=true
# Terraform code
COPY ${TERRAFORM_MODULE_SRC_DIR} ${TERRAFORM_MODULE_SRC_DIR}
RUN terraform-provider-sync
COPY pyproject.toml uv.lock ./
# Test lock file is up to date
RUN uv lock --locked
# Install dependencies
RUN uv sync --frozen --no-group dev --no-install-project --python /usr/bin/python3
# the source code
COPY README.md ./
COPY hooks ./hooks
COPY hooks_lib ./hooks_lib
COPY er_aws_elasticache ./er_aws_elasticache
# Sync the project
RUN uv sync --frozen --no-group dev
FROM base AS prod
# get cdktf providers
COPY --from=builder ${TF_PLUGIN_CACHE_DIR} ${TF_PLUGIN_CACHE_DIR}
# get our app with the dependencies
COPY --from=builder ${APP} ${APP}
FROM prod AS test
COPY --from=ghcr.io/astral-sh/uv:0.6.14@sha256:3362a526af7eca2fcd8604e6a07e873fb6e4286d8837cb753503558ce1213664 /uv /bin/uv
# install test dependencies
RUN uv sync --frozen
COPY Makefile ./
COPY tests ./tests
RUN make in_container_test