Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: Keboola Component Build & Deploy Pipeline
on:
push:
branches:
- 'feature/*'
- 'bug/*'
- feature/*
- bug/*
- fix/*
tags:
- '*' # Skip the workflow on the main branch without tags
- "*" # Skip the workflow on the main branch without tags

concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR
env:
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# RUN apt-get update && apt-get install -y build-essential

# Create user to correctly set the $HOME env variable (used by certain packages, eg. stanza, for caching data)
ARG USERNAME=keboola
RUN adduser --uid 1000 --disabled-password ${USERNAME}

# Set UV_CACHE_DIR to override XDG_CACHE_HOME from the base image
# See https://docs.astral.sh/uv/concepts/cache/#cache-directory
RUN mkdir -p /.cache/uv
Expand All @@ -12,24 +16,28 @@ ENV UV_CACHE_DIR="/.cache/uv"
# Using the same path as venv defined in the base image so we can use all the preinstalled packages
ENV UV_PROJECT_ENVIRONMENT="/home/default/"

# Run uv sync as uid/gid 1000 so we don't have to chown the /home/default directory with 100k files =-O
USER 1000:1000

WORKDIR /code/
COPY pyproject.toml .
COPY uv.lock .

# Run uv sync as uid/gid 1000 so we don't have to chown the /home/default directory with 100k files =-O
USER 1000:1000
# The --inexact flag prevents uv from uninstalling the preinstalled packages
RUN uv sync --all-groups --frozen --inexact

# Keboola running containers with "-u 1000:1000" causes permission when installing user defined packages
# Keboola running containers with "-u 1000:1000" causes permission issues when installing user defined packages
# so we need to chown the files to 1000:1000
USER root
RUN chown 1000:1000 /code/pyproject.toml
RUN chown 1000:1000 /code/uv.lock
RUN chown 1000:1000 pyproject.toml
RUN chown 1000:1000 uv.lock

COPY src/ src/
COPY tests/ tests/
COPY scripts/ scripts/
COPY flake8.cfg .
COPY deploy.sh .

RUN chown -R 1000:1000 *

CMD ["uv", "run", "python", "src/component.py"]
3 changes: 2 additions & 1 deletion src/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ def script_excerpt(script):
@staticmethod
def install_packages(packages):
for package in packages:
logging.info("Installing package: %s...", package)
args = [
"uv",
"add",
package,
]
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
logging.info(f"Installing package: {package}. Full log in detail.", extra={"full_message": stdout})
process.poll()
logging.info("Installation finished: %s. Full log in detail.", package, extra={"full_message": stdout})
if process.poll() != 0:
raise UserException(f"Failed to install package: {package}. Log in event detail.", stderr)
elif stderr:
Expand Down