Skip to content

Commit

Permalink
feat(monodocs): Containerize the conda-lock executable
Browse files Browse the repository at this point in the history
Signed-off-by: Chi-Sheng Liu <[email protected]>
  • Loading branch information
MortalHappiness committed Mar 4, 2024
1 parent 3ad3c40 commit dcbd4bf
Show file tree
Hide file tree
Showing 5 changed files with 787 additions and 855 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
_build/
_bin/
build/
.tmp_build/
.vscode/
*.swp
*.swo
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile.conda-lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM condaforge/mambaforge:latest

ARG USER_UID
ARG USER_GID

RUN groupadd --gid "${USER_GID}" flyte \
&& useradd --uid "${USER_UID}" --gid "${USER_GID}" -m flyte

RUN conda install -c conda-forge conda-lock
WORKDIR flyte
USER flyte
ENTRYPOINT ["conda", "run", "--no-capture-output", "conda-lock"]
7 changes: 7 additions & 0 deletions Dockerfile.docs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM condaforge/mambaforge:latest

ARG USER_UID
ARG USER_GID

RUN groupadd --gid "${USER_GID}" flyte \
&& useradd --uid "${USER_UID}" --gid "${USER_GID}" -m flyte

RUN conda install -c conda-forge conda-lock
RUN --mount=type=bind,source=monodocs-environment.lock.yaml,target=monodocs-environment.lock.yaml \
conda-lock install -n monodocs-env monodocs-environment.lock.yaml
Expand All @@ -11,4 +17,5 @@ RUN python -m pip install sphinx-autobuild
RUN python -m pip install ./flyteidl

WORKDIR docs
USER flyte
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "monodocs-env"]
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GIT_HASH := $(shell git rev-parse --short HEAD)
TIMESTAMP := $(shell date '+%Y-%m-%d')
PACKAGE ?=github.com/flyteorg/flytestdlib
LD_FLAGS="-s -w -X $(PACKAGE)/version.Version=$(GIT_VERSION) -X $(PACKAGE)/version.Build=$(GIT_HASH) -X $(PACKAGE)/version.BuildTime=$(TIMESTAMP)"
TMP_BUILD_DIR := .tmp_build

.PHONY: cmd/single/dist
cmd/single/dist: export FLYTECONSOLE_VERSION ?= latest
Expand Down Expand Up @@ -89,23 +90,29 @@ helm_upgrade: ## Upgrade helm charts
docs:
make -C docs clean html SPHINXOPTS=-W

monodocs-environment.lock.yaml: monodocs-environment.yaml
conda-lock lock --file monodocs-environment.yaml --lockfile monodocs-environment.lock.yaml --channel conda-forge
$(TMP_BUILD_DIR):
mkdir $@

# Used in local development
.PHONY: build-dev-docs-image
build-dev-docs-image: monodocs-environment.lock.yaml
docker buildx build -t flyte-dev-docs:latest -f Dockerfile.docs .
$(TMP_BUILD_DIR)/conda-lock-image: Dockerfile.conda-lock | $(TMP_BUILD_DIR)
docker buildx build --build-arg USER_UID=$$(id -u) --build-arg USER_GID=$$(id -g) -t flyte-conda-lock:latest -f Dockerfile.conda-lock .
touch $(TMP_BUILD_DIR)/conda-lock-image

monodocs-environment.lock.yaml: monodocs-environment.yaml $(TMP_BUILD_DIR)/conda-lock-image
docker run --rm --pull never -v ./:/flyte flyte-conda-lock:latest lock --file monodocs-environment.yaml --lockfile monodocs-environment.lock.yaml --channel conda-forge

$(TMP_BUILD_DIR)/dev-docs-image: Dockerfile.docs monodocs-environment.lock.yaml | $(TMP_BUILD_DIR)
docker buildx build --build-arg USER_UID=$$(id -u) --build-arg USER_GID=$$(id -g) -t flyte-dev-docs:latest -f Dockerfile.docs .
touch $(TMP_BUILD_DIR)/dev-docs-image

# Build docs in docker container for local development
.PHONY: dev-docs-build
dev-docs-build: build-dev-docs-image
docker run --rm --pull never -v ./docs:/docs --user $$(id -u):$$(id -g) flyte-dev-docs:latest sphinx-build -M html . _build
dev-docs-build: $(TMP_BUILD_DIR)/dev-docs-image
docker run --rm --pull never -v ./docs:/docs flyte-dev-docs:latest sphinx-build -M html . _build

# Build docs in docker container for local development with hot-reload
.PHONY: dev-docs
dev-docs: build-dev-docs-image
docker run --rm --pull never -p 8000:8000 -v ./docs:/docs --user $$(id -u):$$(id -g) flyte-dev-docs:latest sphinx-autobuild --host 0.0.0.0 --re-ignore '_build|_src|_tags|api|examples|flytectl|flytekit|flytesnacks|protos|tests' . ./_build/html
dev-docs: $(TMP_BUILD_DIR)/dev-docs-image
docker run --rm --pull never -p 8000:8000 -v ./docs:/docs flyte-dev-docs:latest sphinx-autobuild --host 0.0.0.0 --re-ignore '_build|_src|_tags|api|examples|flytectl|flytekit|flytesnacks|protos|tests' . ./_build/html

.PHONY: help
help: SHELL := /bin/sh
Expand Down
Loading

0 comments on commit dcbd4bf

Please sign in to comment.