Comments (1)
Hello,
I recommend packing the component as a wheel package and then copying it to the Docker image.
Here is the documentation that describes how to build the wheel package.
https://docs.streamlit.io/library/components/publish#build-a-python-wheel (section: "Build a Python wheel")
Here is the documentation that describes how to build a Docker image.
https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker
If you would like to build the wheel package and the docker image, you can also do it in one Dockerfile, but then I recommend using multistage build to limit the size of the final image.
An example Dockerfile might look like this, building a component in a separate stage and then copying the file into the final image.
# syntax=docker/dockerfile:1.4
FROM python:3.9-slim-bullseye as streamlit-app-component-build-image
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY ./examples/RadioButton/ /src/
WORKDIR /src/
# Build frontend
RUN cd /src/radio_button/frontend/ \
&& npm install \
&& npm run build
# Set RELEASE flag to True
RUN sed -i 's/_RELEASE = False/_RELEASE = True/' /src/radio_button/__init__.py
# Build wheel package
RUN python setup.py bdist_wheel --universal sdist
FROM python:3.9-slim-bullseye as streamlit-app-final-image
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-c"]
WORKDIR /app
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
COPY ./app/ /app/
COPY --from=0 /src/dist/streamlit_radio_button-0.0.1-py2.py3-none-any.whl /component-whl/
RUN pip3 install streamlit /component-whl/*.whl
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
from component-template.
Related Issues (20)
- Bug: Error with Typescript version when running react template HOT 2
- How do I change "Click me" Button to custom name ? HOT 3
- Add children to a custom component HOT 1
- Unable to start frontend server for react template HOT 7
- Include tests HOT 1
- Update react-scripts to 5.0.0 HOT 3
- An issue happens at npm run start HOT 1
- plotly_event conflict with st.plotly_chart(fig, use_container_width=True) HOT 1
- Npm start crashes HOT 1
- Failed to compile HOT 2
- ERROR in /node_modules/streamlit-component-lib/dist/ArrowTable.js HOT 3
- Problem with npm install HOT 3
- Optional tooltip HOT 1
- Component not visible in Streamlit component gallery HOT 3
- Quick Start Guide Not Working HOT 4
- Is there a way to get the transparent loading for custom components?
- Split dependencies HOT 1
- Bi-directional component instructions not working on synced Google Drive on Windows - npm install error HOT 1
- Is there way to use react 18 version for this component template? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from component-template.