-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.dev
More file actions
64 lines (53 loc) · 2.08 KB
/
Dockerfile.dev
File metadata and controls
64 lines (53 loc) · 2.08 KB
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
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
# Create appuser with configurable UID and GID to avoid permission issues
# You can override these values at build time like this:
# docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g)
# This ensures that files created in volumes or bind mounts are owned by the correct host user
ARG UID=1000
ARG GID=1000
# Install the project into `/app`
WORKDIR /app
# Install tools
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
bison \
flex \
libboost-all-dev \
curl \
git \
iproute2 \
iputils-ping \
jq \
procps \
tar \
vim \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install grpcurl (gRPC command-line tool)
ARG GRPCURL_VERSION=1.9.3
RUN curl -L https://github.com/fullstorydev/grpcurl/releases/download/v${GRPCURL_VERSION}/grpcurl_${GRPCURL_VERSION}_linux_x86_64.tar.gz \
| tar -xz -C /usr/local/bin
# Add user
RUN groupadd -g ${GID} appuser \
&& useradd -m -u ${UID} -g ${GID} -s /bin/bash -c "" appuser \
&& chown -R appuser:appuser /app
USER appuser
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Increase HTTP timeout for downloading packages (in seconds)
ENV UV_HTTP_TIMEOUT=300
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=~/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev --no-group qubex
# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
COPY --chown=appuser:appuser . /app
RUN --mount=type=cache,target=~/.cache/uv \
uv sync --locked --no-dev --no-group qubex
# Run the application
CMD ["uv", "run", "python", "src/device_gateway/service.py", "-c", "config/config.yaml", "-l", "config/logging.yaml"]