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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
- name: Check-out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Build Dev Docker Image
- name: Build Docker Image
run: |
make docker_build

- name: Build Development Docker Image and Run Pre-commit
run: |
make docker_pre_commit_action
44 changes: 44 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION} AS base
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV TEST_WORKSPACE=/app


# Change the working directory to the `app` directory
WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy


# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project

# Copy the project into the image
COPY . /app

COPY /src/sc2anonserverpy/grpc_server.py \
/src/sc2anonserverpy/grpc_client.py \
/app/

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

# Reset the entrypoint, don't invoke "python" by default
ENTRYPOINT []


CMD [ "sh" ]
37 changes: 34 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ PYTHON_VERSION = 3.13
# Docker variables:
DOCKER_DIR = ./docker
DOCKER_FILE = $(DOCKER_DIR)/Dockerfile
DOCKER_FILE_DEVCONTAINER = $(DOCKER_DIR)/Dockerfile.dev

DOCKER_TAG = kaszanas/sc2anonserverpy
DEVCONTAINER = kaszanas/sc2anonserverpy-devcontainer

############################
#### Using the tools #######
Expand All @@ -19,11 +21,16 @@ run_server: ## Run the server
python3 grpc_server.py

.PHONY: run_client
run_client: ## Run the client
run_client: ## Run the client without multiprocessing
docker run -it --rm \
-v ".\processing:/app/processing"
$(DOCKER_TAG) \
python3 grpc_client.py

python3 grpc_client.py \
--input_dir /app/processing/demos/input \
--output_dir /app/processing/demos/output \
--agents 1 \
--chunksize 1 \
--use_multiprocessing False

############################
#### Docker commands #######
Expand All @@ -43,6 +50,30 @@ docker_run_it: ## Run the container in interactive mode
docker run -it --rm $(DOCKER_TAG)


.PHONY: docker_build_devcontainer
docker_build_devcontainer: ## Builds the devcontainer image.
@echo "Building the Dockerfile: $(DOCKER_FILE_DEVCONTAINER)"
@echo "Setting tag to: $(DEVCONTAINER)"
@echo "Using Python version: $(PYTHON_VERSION)"
docker build \
--build-arg="PYTHON_VERSION=$(PYTHON_VERSION)" \
-f $(DOCKER_FILE_DEVCONTAINER) . \
--tag=$(DEVCONTAINER)


############################
#### GitHub Actions ########
############################
.PHONY: docker_pre_commit_action
docker_pre_commit_action: ## Runs pre-commit hooks using Docker.
@echo "Running pre-commit hooks using Docker."
@make docker_build_devcontainer
@echo "Using the devcontainer image: $(DEVCONTAINER)"
docker run \
$(DEVCONTAINER) \
pre-commit run --all-files


.PHONY: help
help: ## Show available make targets
@awk '/^[^\t ]*:.*?##/{sub(/:.*?##/, ""); printf "\033[36m%-30s\033[0m %s\n", $$1, substr($$0, index($$0,$$2))}' $(MAKEFILE_LIST)