Skip to content

Commit

Permalink
Merge pull request #14 from childmindresearch/dockerfile
Browse files Browse the repository at this point in the history
Add dockerfile
  • Loading branch information
kaitj authored Jul 26, 2024
2 parents 7249c43 + 295a780 commit 5e151ea
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy_container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy Docker image
on:
push:
tags:
- "*"

env:
REGISTRY: ghcr.io
IMG_NAME: ${{ github.repository }}

jobs:
docker_build_and_push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract tags, labels for image
id: metadata
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMG_NAME }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG PY_VERSION=3.11
FROM python:${PY_VERSION}-slim-bookworm as python
RUN apt-get update -qq \
&& apt-get install -y -q --no-install-recommends \
build-essential \
ffmpeg \
libcurl4 \
git \
openssl \
&& python -m pip install --upgrade pip \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


# NOTE: Set version to be able to checkout tag in future
# (for now, installing latest from `main`)
FROM python as builder
ARG NIFTYONE_VER=0.0.0
COPY . /opt/niftyone/
RUN cd /opt/niftyone \
&& pip wheel --no-deps --prefer-binary .

FROM builder as runtime
WORKDIR /home
ENV OS=LINUX
RUN WHEEL=`ls /opt/niftyone | grep whl` \
&& pip install /opt/niftyone/${WHEEL} \
&& rm -r /opt/niftyone \
&& apt-get --purge -y -qq autoremove
EXPOSE 5151
ENTRYPOINT ["niftyone"]

0 comments on commit 5e151ea

Please sign in to comment.