-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathContainerfile.dev
162 lines (145 loc) · 4.45 KB
/
Containerfile.dev
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Dev container with packages from git.
FROM ubuntu:24.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# install system dependencies
RUN apt update && \
apt install -y \
curl \
unzip \
git \
ca-certificates \
build-essential \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
python3-dev python3-pip && \
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && \
bash nodesource_setup.sh && \
apt install -y nodejs && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
# install bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH=/root/.bun/bin:${PATH}
# install python dependencies
RUN pip3 install --break-system-packages --upgrade build twine
COPY requirements/main.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages -r /tmp/requirements.txt && \
rm -f /tmp/requirements.txt
#
#
# build the python dependency from git
RUN git clone https://github.com/waldiez/python.git /tmp/package/python && \
cd /tmp/package/python && \
git checkout main && \
mkdir -p /tmp/python && \
python3 -m build --sdist --wheel --outdir /tmp/python/dist/ && \
rm -rf /tmp/package/python
#
WORKDIR /tmp/package
ENV WALDIEZ_STUDIO_BASE_URL=/frontend/
#
# copy source code
COPY . /tmp/package
#
# build the package
#
# try to build the frontend even with low memory
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN git clone https://github.com/waldiez/react.git /tmp/react && \
cd /tmp/react && \
git checkout main && \
jq -r .version package.json > /tmp/version && \
bun install && \
bun run build && \
cd /tmp/package && \
bun install && \
bun pm cache rm && \
bun remove @waldiez/react && \
bun add @waldiez/react@../react/out/archive/waldiez-react-$(cat /tmp/version).tgz && \
bun install && \
rm -rf /tmp/react /tmp/version && \
bun run build && \
python3 -m build --sdist --wheel --outdir /tmp/dist/ && \
cd / && \
rm -rf /tmp/package
# Final image
FROM python:3.12-slim
LABEL maintainer="waldiez <[email protected]>"
LABEL org.opencontainers.image.source="quay.io/waldiez/studio"
LABEL org.opencontainers.image.title="waldiez/studio"
LABEL org.opencontainers.image.description="Waldiez Studio"
# set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV DEBIAN_FRONTEND="noninteractive"
ENV DEBCONF_NONINTERACTIVE_SEEN=true
# install system dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends \
tzdata \
locales \
bzip2 \
ca-certificates \
build-essential \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
wget \
fonts-liberation \
git \
sudo \
openssl \
curl \
tini \
zip \
unzip \
graphviz && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen en_US.UTF-8 && \
apt clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
LC_CTYPE=en_US.UTF-8 \
TZ=Etc/UTC
# I prefer colors
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
# create a non-root user
ARG GROUP_ID=1000
ENV GROUP_ID=${GROUP_ID}
RUN addgroup --system --gid ${GROUP_ID} user
ARG USER_ID=1000
ENV USER_ID=${USER_ID}
RUN adduser --disabled-password --gecos '' --shell /bin/bash --uid ${USER_ID} --gid ${GROUP_ID} user
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
RUN mkdir -p /home/user/tmp /home/user/.local/bin && \
chown -R user:user /home/user
ENV PATH=/home/user/.local/bin:${PATH}
USER user
RUN pip install --upgrade pip
COPY --from=builder --chown=user:user /tmp/dist/*.whl /home/user/tmp/
COPY --from=builder --chown=user:user /tmp/python/dist/*.whl /home/user/python_tmp/
RUN pip install --user /home/user/tmp/*.whl && \
pip install --user /home/user/python_tmp/*.whl && \
rm -rf /home/user/tmp /home/user/python_tmp
ARG WALDIEZ_STUDIO_PORT=8000
ENV WALDIEZ_STUDIO_PORT=${WALDIEZ_STUDIO_PORT}
EXPOSE ${WALDIEZ_STUDIO_PORT}
# we are in docker, so 'localhost' might not work
ENV WALDIEZ_STUDIO_HOST=0.0.0.0
ENV WALDIEZ_STUDIO_TRUSTED_HOSTS=0.0.0.0,localhost
ENV TINI_SUBREAPER=true
ENTRYPOINT ["/usr/bin/tini", "--"]
WORKDIR /home/user
CMD ["waldiez-studio"]