-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build a container from a project #113
Comments
If we are satisfied with relying on the official Miniconda image, I think we could potentially do something simple with templating very easily. Here is a stripped example using FROM continuumio/miniconda3:latest
# Copy the conda environment config and install dependencies
COPY environment.yml /environment.yml
RUN conda env create -p /conda -f environment.yml
# Link conda to global path and
ENV PATH=/conda/bin:$PATH
WORKDIR /app
# Copy the application code
COPY . .
# Expose the port and run the service
EXPOSE 8000
ENTRYPOINT ["python", "-m", "my_service"]
CMD ["serve"] |
here's one I have that works FROM continuumio/miniconda3 as miniconda
### Install and configure miniconda
RUN conda install conda-forge::conda-project --yes && conda clean --all --yes
FROM miniconda as conda-project
COPY --from=miniconda /opt/conda /opt/conda
### Set timezone
ENV TZ=US/Central
RUN cp /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PATH=/opt/conda/bin:$PATH
ENV HOME=/project
COPY . /project
RUN chown -R 1001:1001 /project
USER 1001
WORKDIR /project
RUN ["conda", "project", "install"]
ENTRYPOINT ["conda", "project", "run"]
CMD [] This means from your project directory you can
I have caught a bug where a locked project on my desktop decides that it's no longer locked when being installed inside |
Oh awesome, that's way better. Sounds like we could add a basic MVP subcommand that just embeds that file and renders it to run the docker build command. Then, if we find any need for more complexity we can explore a templating engine like jinja2 if appropriate. |
What is the purpose of the time zone? |
I started putting that in my dockerfiles after working on some timeseries data and realizing that timezone support wasn't something that "just worked" for me. It's strictly not required here. |
There is one aspect that needs to be considered here. The blind |
I recommend we respect the same ignore rules as the archive command. We may even get this for free with .dockerignore (if we were to build one when the command runs or if we can override a docker build argument). Something to investigate. |
@AlbertDeFusco removed bug label, felt like a mistake. Feel free to put back if you intended it. |
@AlbertDeFusco you may want to look into using
|
So you think we might do something like this to publish a builder and runtime image to dockerhub so the project author has a dockerfile with as little as two lines in it? https://www.busbud.com/blog/going-docker-multi-stage-builds/ |
That's really interesting! I was thinking about whether a conda-project-specific image would be worthwhile but I started imagining the combinatorial aspects of "which miniconda + which conda-project version". But maybe that isn't a real concern if it's always "latest bundled with latest"? I need to grok that |
I was working on this some more and discovered two issues to keep track of:
|
On 1. We have some question about whether we persist the generated On 2. Are the channels the same? I'm guessing the channels or OS at least are different and there may be a different version of a dependency based on the availability of a package for arm64? Just a guess. |
I've just come across this project, which may be worth considering integrating: https://github.com/conda-incubator/conda-docker |
It would be useful to have a way to create a docker image for a defined command in a conda-project.yml file.
For reference, the
anaconda-project dock
subcommand utilized a source-to-image builder image defined in https://github.com/Anaconda-Platform/s2i-anaconda-project.docs: https://anaconda-project.readthedocs.io/en/latest/user-guide/tasks/docker-image.html
The text was updated successfully, but these errors were encountered: