-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathContainerfile
115 lines (96 loc) · 3.13 KB
/
Containerfile
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
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 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 curl && \
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}
WORKDIR /tmp/package
# 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
# copy source code
COPY . /tmp/package
# build the frontend
ENV WALDIEZ_STUDIO_BASE_URL=/frontend/
RUN bun install && bun run build
# build the backend
RUN python3 -m build --sdist --wheel --outdir dist/
# 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 \
wget \
fonts-liberation \
git \
sudo \
openssl \
curl \
tini \
zip \
unzip && \
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/package/dist/*.whl /home/user/tmp/
RUN pip install --user /home/user/tmp/*.whl && \
rm -rf /home/user/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"]