@@ -28,6 +28,7 @@ import io.seqera.wave.api.ImageNameStrategy
2828import io.seqera.wave.api.PackagesSpec
2929import io.seqera.wave.api.SubmitContainerTokenRequest
3030import io.seqera.wave.config.CondaOpts
31+ import io.seqera.wave.config.PixiOpts
3132import io.seqera.wave.exception.BadRequestException
3233import io.seqera.wave.service.request.ContainerRequest
3334import io.seqera.wave.service.builder.BuildFormat
@@ -603,4 +604,97 @@ class ContainerHelperTest extends Specification {
603604
604605 }
605606
607+
608+ // === build with pixi tests
609+
610+ def ' should create conda docker file with packages and pixi' () {
611+ given :
612+ def CHANNELS = [' conda-forge' , ' defaults' ]
613+ def PACKAGES = [' bwa=0.7.15' , ' salmon=1.1.1' ]
614+ def packages = new PackagesSpec (
615+ type : PackagesSpec.Type . CONDA ,
616+ entries : PACKAGES ,
617+ channels : CHANNELS )
618+ and :
619+ def req = new SubmitContainerTokenRequest (packages :packages, buildTemplate : ' pixi/v1' )
620+ when :
621+ def result = ContainerHelper . containerFileFromRequest(req)
622+
623+ then :
624+ result == ''' \
625+ FROM ghcr.io/prefix-dev/pixi:latest AS build
626+
627+ COPY conda.yml /opt/wave/conda.yml
628+ WORKDIR /opt/wave
629+
630+ RUN pixi init --import /opt/wave/conda.yml \\
631+ && pixi add conda-forge::procps-ng \\
632+ && pixi shell-hook > /shell-hook.sh \\
633+ && echo 'exec "$@"' >> /shell-hook.sh \\
634+ && echo ">> CONDA_LOCK_START" \\
635+ && cat /opt/wave/pixi.lock \\
636+ && echo "<< CONDA_LOCK_END"
637+
638+ FROM ubuntu:24.04 AS prod
639+
640+ # copy the pixi environment in the final container
641+ COPY --from=build /opt/wave/.pixi/envs/default /opt/wave/.pixi/envs/default
642+ COPY --from=build /shell-hook.sh /shell-hook.sh
643+
644+ # set the entrypoint to the shell-hook script (activate the environment and run the command)
645+ # no more pixi needed in the prod container
646+ ENTRYPOINT ["/bin/bash", "/shell-hook.sh"]
647+
648+ # Default command for "docker run"
649+ CMD ["/bin/bash"]
650+ ''' . stripIndent()
651+ }
652+
653+ def ' should create conda docker file with packages and pixi custom image' () {
654+ given :
655+ def CHANNELS = [' conda-forge' , ' defaults' ]
656+ def PIXI_OPTS = new PixiOpts (
657+ basePackages : ' foo::one bar::two' ,
658+ baseImage : ' base/image' ,
659+ pixiImage : ' ghcr.io/prefix-dev/pixi:0.47.0-jammy-cuda-12.8.1' )
660+ def PACKAGES = [' bwa=0.7.15' , ' salmon=1.1.1' ]
661+ def packages = new PackagesSpec (
662+ type : PackagesSpec.Type . CONDA ,
663+ entries : PACKAGES ,
664+ channels : CHANNELS ,
665+ pixiOpts : PIXI_OPTS )
666+ and :
667+ def req = new SubmitContainerTokenRequest (packages :packages, buildTemplate : ' pixi/v1' )
668+ when :
669+ def result = ContainerHelper . containerFileFromRequest(req)
670+
671+ then :
672+ result == ''' \
673+ FROM ghcr.io/prefix-dev/pixi:0.47.0-jammy-cuda-12.8.1 AS build
674+
675+ COPY conda.yml /opt/wave/conda.yml
676+ WORKDIR /opt/wave
677+
678+ RUN pixi init --import /opt/wave/conda.yml \\
679+ && pixi add foo::one bar::two \\
680+ && pixi shell-hook > /shell-hook.sh \\
681+ && echo 'exec "$@"' >> /shell-hook.sh \\
682+ && echo ">> CONDA_LOCK_START" \\
683+ && cat /opt/wave/pixi.lock \\
684+ && echo "<< CONDA_LOCK_END"
685+
686+ FROM base/image AS prod
687+
688+ # copy the pixi environment in the final container
689+ COPY --from=build /opt/wave/.pixi/envs/default /opt/wave/.pixi/envs/default
690+ COPY --from=build /shell-hook.sh /shell-hook.sh
691+
692+ # set the entrypoint to the shell-hook script (activate the environment and run the command)
693+ # no more pixi needed in the prod container
694+ ENTRYPOINT ["/bin/bash", "/shell-hook.sh"]
695+
696+ # Default command for "docker run"
697+ CMD ["/bin/bash"]
698+ ''' . stripIndent()
699+ }
606700}
0 commit comments