diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 3c9f4039e4..0bce90f097 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -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 + push: ${{ github.event_name == 'release' }} + tags: ${{ steps.flyin-names.outputs.tags }} + build-args: | + VERSION=${{ needs.deploy.outputs.version }} + file: ./plugins/flytekit-flyin/Dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/plugins/flytekit-flyin/Dockerfile b/plugins/flytekit-flyin/Dockerfile new file mode 100644 index 0000000000..213ac1a665 --- /dev/null +++ b/plugins/flytekit-flyin/Dockerfile @@ -0,0 +1,46 @@ +ARG PYTHON_VERSION +FROM python:${PYTHON_VERSION}-slim-buster +MAINTAINER Flyte Team +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 \ + && 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