Skip to content

A docker image for the magic package manager

License

Notifications You must be signed in to change notification settings

modular/magic-docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

magic-docker (based on pixi-docker)

This repository contains the docker configuration for the magic container image. The magic container image is based on different base images, depending on the use case. All images have magic installed in /usr/local/bin/magic and are ready to use.

Pulling the images

The images are available on "GHCR" (Github Container Registry). You can pull them using docker like so:

docker pull ghcr.io/modular/magic:latest

There are different tags for different base images available:

  • latest - based on ubuntu:jammy
  • focal - based on ubuntu:focal
  • bullseye - based on debian:bullseye
  • jammy-cuda-12.2.2 - based on nvidia/cuda:12.2.2-jammy
  • ... and more

Usage with shell-hook

The following example uses the magic docker image as a base image for a multi-stage build. It also makes use of the shell-hook feature of magic to define a convenient entry point (after executing the shell-hook script, the environment is activated.

FROM ghcr.io/prefix-dev/magic:latest AS build

# copy source code, pixi.toml and magic.lock to the container
COPY . /app
WORKDIR /app
# run some compilation / build task (if needed)
RUN magic run build
# run the `install` command (or any other). This will also install the dependencies into `/app/.magic`
# assumes that you have a `prod` environment defined in your pixi.toml
RUN magic run install -e prod
# Create the shell-hook bash script to activate the environment
RUN magic shell-hook -e prod > /shell-hook.sh

# extend the shell-hook script to run the command passed to the container
RUN echo 'exec "$@"' >> /shell-hook.sh

FROM ubuntu:22.04 AS production

# only copy the production environment into prod container
# please note that the "prefix" (path) needs to stay the same as in the build container
COPY --from=build /app/.magic/envs/prod /app/.magic/envs/prod
COPY --from=build /shell-hook.sh /shell-hook.sh
WORKDIR /app
EXPOSE 8000

# set the entrypoint to the shell-hook script (activate the environment and run the command)
# no more magic needed in the prod container
ENTRYPOINT ["/bin/bash", "/shell-hook.sh"]

CMD ["start-server"]

Images

There are images based on ubuntu, debian and nvidia/cuda available.

Ubuntu

The ubuntu:jammy (22.04) based image is the default base image. It is used for the latest and 0.x.y tag.

There are also images based on ubuntu:focal (20.04), ubuntu:mantic (23.10) and ubuntu:noble (24.04) available. These images use the tags focal, 0.x.y-focal, ...

Debian

Images based on debian:bullseye, debian:bullseye-slim (11), debian:bookworm and debian:bookworm-slim (12) are available.

These images have the tags bullseye, 0.x.y-bullseye, ...

NVIDIA/CUDA

Images based on nvidia/cuda are available using the tags cuda-<cuda-version>-jammy, cuda-<cuda-version>-focal, 0.x.y-cuda-<cuda-version>-jammy, ...

About

A docker image for the magic package manager

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Dockerfile 90.7%
  • Python 9.3%