Skip to content

Commit 32ab7a2

Browse files
committed
Switch to pixi package manager
1 parent 94462c4 commit 32ab7a2

File tree

12 files changed

+4995
-94
lines changed

12 files changed

+4995
-94
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Dockerfile
1010
LICENSE
1111
CHRIS_REMOTE_FS
1212
swift_storage
13+
14+
dist/
15+
.pixi/
16+

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GitHub syntax highlighting
2+
pixi.lock linguist-language=YAML linguist-generated=true

.github/workflows/ci.yml

+28-12
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,40 @@ jobs:
3838

3939
build:
4040
needs: [test-pfcon, test-cube]
41-
if: github.event_name == 'push' || github.event_name == 'release'
4241
runs-on: ubuntu-22.04
4342
steps:
4443
- uses: actions/checkout@v4
44+
- name: Install pixi
45+
id: install-pixi
46+
if: startsWith(github.ref, 'refs/tags/v')
47+
uses: prefix-dev/setup-pixi@v0.8.1
4548
with:
46-
fetch-depth: "0"
49+
pixi-version: v0.28.2
50+
- name: Set version
51+
id: set-version
52+
if: steps.install-pixi.outcome == "success"
53+
run:
54+
ref_name='${{ github.ref_name }}'
55+
version_number="${ref_name:1}"
56+
pixi project version set "$version_number"
57+
echo "LABEL org.opencontainers.image.version=\"$version_number\"" >> Dockerfile
58+
echo "version=$version_number" >> "$GITHUB_OUTPUT"
4759
- name: Get build tags
4860
id: info
4961
shell: python
5062
run: |
5163
import os
5264
import itertools
5365
54-
short_sha = os.getenv('GITHUB_SHA', 'unknown')[:7]
66+
commit_sha = '${{ github.sha }}'
67+
short_sha = commit_sha[:7]
5568
git_refs = []
56-
if os.getenv('GITHUB_REF', '').startswith('refs/tags/v'):
57-
version_from_tag = os.getenv('GITHUB_REF')[11:]
58-
git_refs.append(version_from_tag.replace('+', '.'))
69+
version_number = '${{ steps.set-version.outputs.version }}'
70+
if version_number:
71+
sanitized_version_number = version_number.replace('+', '.')
72+
git_refs.append(sanitized_version_number)
5973
registries = ['docker.io', 'ghcr.io']
60-
repo = os.environ['GITHUB_REPOSITORY'].lower()
74+
repo = '${{ github.repository }}'.lower()
6175
tags = ['latest'] + git_refs
6276
names = ','.join(''.join(c) for c in itertools.product(
6377
(r + '/' for r in registries),
@@ -69,24 +83,26 @@ jobs:
6983
- uses: docker/setup-qemu-action@v3
7084
- uses: docker/setup-buildx-action@v3
7185
- name: Login to DockerHub
86+
id: login-dockerhub
87+
if: github.event_name == 'push'
7288
uses: docker/login-action@v3
7389
with:
7490
username: ${{ secrets.DOCKERHUB_USERNAME }}
7591
password: ${{ secrets.DOCKERHUB_PASSWORD }}
7692
- name: Login to GitHub Container Registry
93+
id: login-ghcr
94+
if: github.event_name == 'push'
7795
uses: docker/login-action@v3
7896
with:
7997
registry: ghcr.io
8098
username: ${{ github.repository_owner }}
8199
password: ${{ secrets.GITHUB_TOKEN }}
82100

83101
- name: Build and push
84-
uses: docker/build-push-action@v5
102+
uses: docker/build-push-action@v6
85103
with:
86-
build-args: |
87-
ENVIRONMENT=production
88-
BUILD_VERSION=${{ github.ref_name }}
89-
push: true
104+
build-args: ENVIRONMENT=prod
105+
push: ${{ steps.login-dockerhub.outcome }} == 'success' && ${{ steps.login-ghcr.outcome }} == 'success'
90106
context: .
91107
file: ./Dockerfile
92108
tags: "${{ steps.info.outputs.tags }}"

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717
dc.out
1818
CHRIS_REMOTE_FS/
1919
swift_storage/
20+
21+
# pixi environments
22+
.pixi
23+
*.egg-info

Dockerfile

+19-42
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,32 @@
1-
#
2-
# Docker file for pfcon image
3-
#
4-
# Build production image:
5-
#
6-
# docker build -t <name> .
7-
#
8-
# For example if building a local production image:
9-
#
10-
# docker build -t local/pfcon .
11-
#
12-
# Build development image:
13-
#
14-
# docker build --build-arg ENVIRONMENT=local -t <name>:<tag> .
15-
#
16-
# For example if building a local development image:
17-
#
18-
# docker build --build-arg ENVIRONMENT=local -t local/pfcon:dev .
19-
#
20-
# In the case of a proxy (located at say proxy.tch.harvard.edu:3128), do:
21-
#
22-
# export PROXY="http://proxy.tch.harvard.edu:3128"
23-
#
24-
# then add to any of the previous build commands:
25-
#
26-
# --build-arg http_proxy=${PROXY}
27-
#
28-
# For example if building a local development image:
29-
#
30-
# docker build --build-arg http_proxy=${PROXY} --build-arg ENVIRONMENT=local -t local/pfcon:dev .
31-
#
32-
33-
FROM python:3.10.5-bullseye
1+
FROM ghcr.io/prefix-dev/pixi:0.27.1 AS build
342

3+
COPY . /app
354
WORKDIR /app
365

37-
COPY ./requirements ./requirements
38-
ARG ENVIRONMENT=production
39-
RUN pip install --no-cache-dir -r /app/requirements/$ENVIRONMENT.txt
6+
RUN --mount=type=cache,target=/root/.cache/rattler/cache,sharing=locked pixi install
407

41-
COPY . .
42-
ARG BUILD_VERSION=unknown
43-
RUN if [ "$ENVIRONMENT" = "local" ]; then pip install -e .; else pip install .; fi
8+
RUN pixi run build
449

45-
EXPOSE 5005
10+
ARG ENVIRONMENT=prod
11+
RUN printf '#!/bin/sh\n%s\nexec "$@"' "$(pixi shell-hook -e ${ENVIRONMENT})" > /entrypoint.sh
12+
RUN chmod +x /entrypoint.sh
13+
14+
# must be the last command of this stage, or else pixi will overwrite the installed package.
15+
RUN pixi run postinstall-production
16+
17+
FROM docker.io/library/debian:bookworm-slim
18+
19+
COPY --from=build /app/.pixi/envs/${ENVIRONMENT} /app/.pixi/envs/${ENVIRONMENT}
20+
COPY --from=build /entrypoint.sh /entrypoint.sh
21+
22+
ENTRYPOINT [ "/entrypoint.sh" ]
4623
CMD ["gunicorn", "--bind", "0.0.0.0:5005", "--workers", "8", "--timeout", "3600", "pfcon.wsgi:application"]
4724

25+
EXPOSE 5005
26+
4827
LABEL org.opencontainers.image.authors="FNNDSC <dev@babyMRI.org>" \
4928
org.opencontainers.image.title="pfcon" \
5029
org.opencontainers.image.description="ChRIS compute resource controller" \
5130
org.opencontainers.image.url="https://chrisproject.org/" \
5231
org.opencontainers.image.source="https://github.com/FNNDSC/pfcon" \
53-
org.opencontainers.image.version=$BUILD_VERSION \
54-
org.opencontainers.image.revision=$BUILD_VERSION \
5532
org.opencontainers.image.licenses="MIT"

MANIFEST.in

-2
This file was deleted.

0 commit comments

Comments
 (0)