Skip to content

Commit

Permalink
Set target as dev stage and define CMD
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Aug 29, 2024
1 parent f2f1851 commit 3d578e7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
test-pfcon:
name: tests (pfcon)
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Start Docker Swarm
Expand All @@ -28,7 +28,7 @@ jobs:
docker swarm leave --force
test-cube:
name: tests (CUBE)
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: docker build -t localhost/fnndsc/pfcon .
Expand All @@ -38,7 +38,7 @@ jobs:

build:
needs: [test-pfcon, test-cube]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install pixi
Expand Down
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
FROM ghcr.io/prefix-dev/pixi:0.27.1 AS build
FROM ghcr.io/prefix-dev/pixi:0.27.1 AS install

COPY . /app
WORKDIR /app

RUN --mount=type=cache,target=/root/.cache/rattler/cache,sharing=locked pixi install

# development stage
FROM install AS dev

CMD ["pixi", "run", "python", "-m", "pfcon"]
EXPOSE 5005

# production build stage
FROM install AS build

RUN pixi run build

ARG ENVIRONMENT=prod
RUN printf '#!/bin/sh\n%s\nexec "$@"' "$(pixi shell-hook -e ${ENVIRONMENT})" > /entrypoint.sh
RUN chmod +x /entrypoint.sh

FROM build as prod-build

# must be the last command of this stage, or else pixi will overwrite the installed package.
RUN pixi run postinstall-production

# production minimal image
FROM docker.io/library/debian:bookworm-slim

COPY --from=prod-build /app/.pixi/envs/${ENVIRONMENT} /app/.pixi/envs/${ENVIRONMENT}
COPY --from=prod-build /entrypoint.sh /entrypoint.sh
COPY --from=build /app/.pixi/envs/${ENVIRONMENT} /app/.pixi/envs/${ENVIRONMENT}
COPY --from=build /entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["gunicorn", "--bind", "0.0.0.0:5005", "--workers", "8", "--timeout", "3600", "pfcon.wsgi:application"]
Expand Down
2 changes: 1 addition & 1 deletion swarm/docker-compose_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
image: localhost:5000/fnndsc/pfcon:dev
build:
context: ..
target: build
target: dev
args:
ENVIRONMENT: local
stdin_open: true # docker run -i
Expand Down
2 changes: 1 addition & 1 deletion swarm/docker-compose_dev_innetwork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
image: localhost:5000/fnndsc/pfcon:dev
build:
context: ..
target: build
target: dev
args:
ENVIRONMENT: local
stdin_open: true # docker run -i
Expand Down
2 changes: 1 addition & 1 deletion swarm/docker-compose_dev_innetwork_fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
image: localhost:5000/fnndsc/pfcon:dev
build:
context: ..
target: build
target: dev
args:
ENVIRONMENT: local
stdin_open: true # docker run -i
Expand Down

0 comments on commit 3d578e7

Please sign in to comment.