Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyin Dockerfile #1990

Merged
42 changes: 42 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,45 @@ jobs:
file: ./plugins/flytekit-spark/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max

build-and-push-flyin-images:
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: "${{ secrets.FLYTE_BOT_USERNAME }}"
password: "${{ secrets.FLYTE_BOT_PAT }}"
- name: Prepare flyin Image Names
id: flyin-names
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/${{ github.repository_owner }}/flytekit
tags: |
flyin-latest
flyin-${{ github.sha }}
flyin-${{ needs.deploy.outputs.version }}
- name: Push Flyin Image to GitHub Registry
uses: docker/build-push-action@v2
with:
context: "./plugins/flytekit-flyin/"
platforms: linux/arm64, linux/amd64
eapolinario marked this conversation as resolved.
Show resolved Hide resolved
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.flyin-names.outputs.tags }}
build-args: |
VERSION=${{ needs.deploy.outputs.version }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we missed the python version here (like this). Do we need to have multiple versions of python in this image?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem, thanks a lot!

file: ./plugins/flytekit-flyin/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
46 changes: 46 additions & 0 deletions plugins/flytekit-flyin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim-buster
MAINTAINER Flyte Team <[email protected]>
LABEL org.opencontainers.image.source https://github.com/flyteorg/flytekit
WORKDIR /root
ENV PYTHONPATH /root

ARG VERSION
ARG TARGETARCH

# 1. Update the necessary packages for flytekit
# 2. Install code-server
# 3. Download code-server extensions for Python and Jupyter via wget
# 4. Install flytekit and flytekit-flyin with no cache
# 5. Delete apt cache. Reference: https://gist.github.com/marvell/7c812736565928e602c4
# 6. Some packages will create config file under /home by default, so we need to make sure it's writable
# 7. Change the permission of /tmp, so that others can run command on it
RUN apt-get update \
eapolinario marked this conversation as resolved.
Show resolved Hide resolved
&& apt-get install build-essential git wget -y \
&& mkdir -p /tmp/ \
&& mkdir -p /tmp/code-server \
&& wget --no-check-certificate -O /tmp/code-server/code-server-4.19.0-linux-${TARGETARCH}.tar.gz https://github.com/coder/code-server/releases/download/v4.19.0/code-server-4.19.0-linux-${TARGETARCH}.tar.gz \
&& tar -xzf /tmp/code-server/code-server-4.19.0-linux-${TARGETARCH}.tar.gz -C /tmp/code-server/ \
&& wget --no-check-certificate https://open-vsx.org/api/ms-python/python/2023.20.0/file/ms-python.python-2023.20.0.vsix -P /tmp/code-server \
&& wget --no-check-certificate https://open-vsx.org/api/ms-toolsai/jupyter/2023.9.100/file/ms-toolsai.jupyter-2023.9.100.vsix -P /tmp/code-server \
&& pip install --no-cache-dir -U flytekit-flyin==$VERSION flytekit==$VERSION \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& useradd -u 1000 flytekit \
&& chown flytekit: /root \
&& chown flytekit: /home \
&& chown -R flytekit:flytekit /tmp \
&& chmod 755 /tmp

# Set the environment variable for code-server
ENV PATH="/tmp/code-server/code-server-4.19.0-linux-${TARGETARCH}/bin:${PATH}"

USER flytekit

# Install extensions using code-server
# Execution is performed here as code-server configuration depends on the USER setting
# If we install it as ROOT, the config will be stored in /root/.config/code-server/config.yaml
# Now, the config of code-server will be stored in /home/flytekit/.config/code-server/config.yaml
RUN code-server --install-extension /tmp/code-server/ms-python.python-2023.20.0.vsix \
&& code-server --install-extension /tmp/code-server/ms-toolsai.jupyter-2023.9.100.vsix