-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.backend
84 lines (63 loc) · 3.15 KB
/
Dockerfile.backend
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# BACKEND DEPLOYMENT
# Base stage for the Python environment
FROM python:3.11.6-slim AS base
LABEL org.opencontainers.image.description "Monitoring Vespa observations"
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
POETRY_VERSION=1.7.1
# Install Poetry, Poe the Poet, pre-commit, nginx
RUN --mount=type=cache,target=/root/.cache/pip/ \
pip install poetry==$POETRY_VERSION poethepoet pre-commit
RUN --mount=type=cache,target=/var/cache/apt/ \
--mount=type=cache,target=/var/lib/apt/ \
apt-get update && apt-get install --no-install-recommends --yes curl build-essential gdal-bin libgdal-dev postgresql-client nginx
# Configure GDAL environment variables, adjust according to the installed GDAL version
ENV GDAL_LIBRARY_PATH /usr/lib/libgdal.so
ENV GEOS_LIBRARY_PATH /usr/lib/libgeos_c.so
# Create and activate a virtual environment
RUN python -m venv /opt/vespadb-env
ENV PATH /opt/vespadb-env/bin:$PATH
ENV VIRTUAL_ENV /opt/vespadb-env
WORKDIR /workspaces/vespadb/
RUN mkdir -p /root/.cache/pypoetry/ && mkdir -p /root/.config/pypoetry/ && \
mkdir -p src/vespadb/ && touch src/vespadb/__init__.py && touch README.md
# Development stage setup
FROM base AS dev
# Install DevContainer utilities: zsh, git, and starship prompt. Note: Docker CLI setup has been updated
RUN --mount=type=cache,target=/var/cache/apt/ \
--mount=type=cache,target=/var/lib/apt/ \
apt-get update && apt-get install --yes --no-install-recommends openssh-client git zsh gnupg lsb-release
# Setup Docker repository and install Docker CLI
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && apt-get install --yes --no-install-recommends docker-ce-cli
# Install starship prompt and configure Git
RUN sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- "--yes" && \
git config --system --add safe.directory '*' && \
echo 'eval "$(starship init zsh)"' >> ~/.zshrc \
&& zsh -c 'source ~/.zshrc'
# Copy poetry and project configuration files to the container
COPY poetry.lock* pyproject.toml /workspaces/vespadb/
# Install the project dependencies - make sure to use the virtual environment
RUN poetry install --no-root --no-interaction --no-ansi
ENTRYPOINT ["/workspaces/vespadb/entrypoint.sh"]
CMD ["serve"]
# Application stage setup
FROM base AS app
COPY poetry.lock* pyproject.toml /workspaces/vespadb/
RUN --mount=type=cache,target=/root/.cache/pypoetry/ \
poetry install --only main --no-interaction --no-ansi
COPY . .
# Add entrypoint script
COPY entrypoint.sh /workspaces/vespadb/entrypoint.sh
RUN chmod +x /workspaces/vespadb/entrypoint.sh
# Copy nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Use the entrypoint script
ENTRYPOINT ["/workspaces/vespadb/entrypoint.sh"]
ARG BUILD_BRANCH
ENV BUILD_BRANCH $BUILD_BRANCH
ARG BUILD_COMMIT
ENV BUILD_COMMIT $BUILD_COMMIT
ARG BUILD_TIMESTAMP
ENV BUILD_TIMESTAMP $BUILD_TIMESTAMP