-
Notifications
You must be signed in to change notification settings - Fork 5
/
streamlit-Containerfile
66 lines (52 loc) · 2.27 KB
/
streamlit-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
# Builder image to install dependencies from pyproject and lock file
FROM quay.io/fedora/python-310:latest AS builder
USER root
ENV POETRY_HOME=/opt/poetry \
POETRY_VERSION=1.8.2
# Install Poetry
RUN wget -P /tmp/ https://certs.corp.redhat.com/certs/Current-IT-Root-CAs.pem && \
curl -sSL https://install.python-poetry.org | python - && \
${POETRY_HOME}/bin/poetry config virtualenvs.in-project true && \
${POETRY_HOME}/bin/poetry config certificates.de-cop-nexus.cert /tmp/Current-IT-Root-CAs.pem
# Copy the source code and install dependencies
COPY . /opt/app-root/src/
WORKDIR /opt/app-root/src/
RUN ${POETRY_HOME}/bin/poetry install --only main
# Final image
FROM quay.io/fedora/python-310:latest
LABEL maintainer="[email protected]" \
io.k8s.description="Streamlit" \
io.k8s.display-name="Streamlit" \
io.openshift.tags="et"
USER root
# Update OS and install necessary packages
RUN dnf -y update && \
dnf -y install java-17-openjdk tini wget && \
dnf -y autoremove && \
dnf -y clean all && \
wget -P /etc/pki/ca-trust/source/anchors https://certs.corp.redhat.com/certs/Current-IT-Root-CAs.pem && \
keytool -import -noprompt -keystore /etc/pki/java/cacerts -file /etc/pki/ca-trust/source/anchors/Current-IT-Root-CAs.pem -alias RH-IT-Root-CA -storepass changeit && \
update-ca-trust enable && \
update-ca-trust extract
# Install Poetry in the final stage
ENV POETRY_HOME=/opt/poetry \
PATH="/opt/poetry/bin:$PATH"
RUN curl -sSL https://install.python-poetry.org | python -
# Copy the source code and set up the environment
COPY . /opt/app-root/src/
WORKDIR /opt/app-root/src/
RUN fix-permissions /opt/app-root/src -P && \
echo "" > /opt/app-root/bin/activate
# Copy virtual environment from the builder stage
COPY --from=builder --chown=1001:0 /opt/app-root/src/.venv /opt/app-root/src/.venv
# Install streamlit directly
RUN /opt/app-root/src/.venv/bin/pip install streamlit
# Copy the starter.sh script and set permissions
COPY streamlit-starter.sh /opt/app-root/src/
RUN chmod +x /opt/app-root/src/streamlit-starter.sh
USER 1001
EXPOSE 8501
# Ensure the virtual environment is included in the PATH
ENV PATH="/opt/app-root/src/.venv/bin:$PATH"
# Start the Streamlit app using streamlit-starter.sh
CMD ["/opt/app-root/src/streamlit-starter.sh"]