Skip to content

Commit

Permalink
feat: build and push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKalho committed Dec 11, 2024
1 parent 08ed4c5 commit 7c0caaa
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docker
on:
push:
branches:
- "main"
pull_requests:

env:
REGISTRY: docker.io
IMAGE_NAME: example-compute-block

jobs:
build:
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Extract metadata for docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref, event=pr
type=raw, value=latest, enable=${{ (github.ref == format('refs/heads/{0}', 'main')) }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM python:3.12

ENV PYTHONUNBUFFERED=1

# Install Java for Spark
RUN apt-get update && \
apt-get install -y default-jdk && \
apt-get clean

COPY . ./app

WORKDIR /app

# Using this example-compute-block for testing, you have to copy your current version of scystream-sdk into this
# directory. We copy it into the docker container, and install it there via the folder.
RUN python3 -m venv .venv && \
.venv/bin/pip install --upgrade pip && \
.venv/bin/pip install ./scystream-sdk
COPY requirements.txt /app

RUN pip install --upgrade pip && pip install -r requirements.txt

COPY . /app


ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
# CMD sh -c "python -c 'import main; from scystream.sdk.scheduler import Scheduler; Scheduler.execute_function(\"test_file\")'"

# Keep the container running. Just for testing, normally placeholder which will be overriden by DockerOperator
CMD ["tail", "-f", "/dev/null"]
# Cmd that will be overwritten by Airflow
CMD ["sh", "-c","echo Container is ready for the Scheduler.exectue_function call."]
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ def test_file(settings):
)


if __name__ == "__main__":
Scheduler.execute_function("test_entrypoint")
Scheduler.execute_function("test_file")
# if __name__ == "__main__":
# Scheduler.execute_function("test_entrypoint")
# Scheduler.execute_function("test_file")
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scystream-sdk==1.0

0 comments on commit 7c0caaa

Please sign in to comment.