Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use docker or podman to build and run the UI #98

Merged
merged 2 commits into from
Sep 29, 2021
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
52 changes: 41 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ ifneq ($(GIT_TAG),)
VERSION_METADATA =
endif

# Setting container tool
DOCKER_CMD := $(shell command -v docker 2> /dev/null)
PODMAN_CMD := $(shell command -v podman 2> /dev/null)

ifdef DOCKER_CMD
CONTAINER_TOOL = 'docker'
else ifdef PODMAN_CMD
CONTAINER_TOOL = 'podman'
endif

# HELP
# This will output the help for each task
.PHONY: help
Expand Down Expand Up @@ -66,22 +76,42 @@ prod: ## Start Production server
start: install build ## Start server
@yarn run start

# -- Docker --
# -- Container Runtime --

.PHONY: cbuild
cbuild: ## Build docker image
docker build -t ${REGISTRYNS}/${BINNAME}-builder:${VERSION} --cache-from ${REGISTRYNS}/${BINNAME}-builder:latest --target build_base --build-arg VERSION=${VERSION} .
docker tag ${REGISTRYNS}/${BINNAME}-builder:${VERSION} ${REGISTRYNS}/${BINNAME}-builder:latest
cbuild: ## Build container image
ifndef CONTAINER_TOOL
$(error No container tool (docker, podman) found in your environment. Please, install one)
endif

@echo "Building image with $(CONTAINER_TOOL)"

${CONTAINER_TOOL} build -t ${REGISTRYNS}/${BINNAME}-builder:${VERSION} --cache-from ${REGISTRYNS}/${BINNAME}-builder:latest --target build_base --build-arg VERSION=${VERSION} .
${CONTAINER_TOOL} tag ${REGISTRYNS}/${BINNAME}-builder:${VERSION} ${REGISTRYNS}/${BINNAME}-builder:latest

docker build -t ${REGISTRYNS}/${BINNAME}:${VERSION} --cache-from ${REGISTRYNS}/${BINNAME}-builder:latest --cache-from ${REGISTRYNS}/${BINNAME}:latest --build-arg VERSION=${VERSION} --build-arg "MOVE2KUBE_UI_GIT_COMMIT_HASH=${GIT_COMMIT}" --build-arg "MOVE2KUBE_UI_GIT_TREE_STATUS=${GIT_DIRTY}" .
docker tag ${REGISTRYNS}/${BINNAME}:${VERSION} ${REGISTRYNS}/${BINNAME}:latest
${CONTAINER_TOOL} build -t ${REGISTRYNS}/${BINNAME}:${VERSION} --cache-from ${REGISTRYNS}/${BINNAME}-builder:latest --cache-from ${REGISTRYNS}/${BINNAME}:latest --build-arg VERSION=${VERSION} --build-arg "MOVE2KUBE_UI_GIT_COMMIT_HASH=${GIT_COMMIT}" --build-arg "MOVE2KUBE_UI_GIT_TREE_STATUS=${GIT_DIRTY}" .
${CONTAINER_TOOL} tag ${REGISTRYNS}/${BINNAME}:${VERSION} ${REGISTRYNS}/${BINNAME}:latest

.PHONY: cpush
cpush: ## Push docker image
cpush: ## Push container image
ifndef CONTAINER_TOOL
$(error No container tool (docker, podman) found in your environment. Please, install one)
endif

@echo "Pushing image with $(CONTAINER_TOOL)"
# To help with reusing layers and hence speeding up build
docker push ${REGISTRYNS}/${BINNAME}-builder:${VERSION}
docker push ${REGISTRYNS}/${BINNAME}:${VERSION}
${CONTAINER_TOOL} push ${REGISTRYNS}/${BINNAME}-builder:${VERSION}
${CONTAINER_TOOL} push ${REGISTRYNS}/${BINNAME}:${VERSION}

.PHONY: crun
crun: ## Run using docker
docker run --rm -it -p 8080:8080 -v ${PWD}/data:/move2kube-api/data -v /var/run/docker.sock:/var/run/docker.sock quay.io/konveyor/move2kube-ui:latest
crun: ## Run using container image
ifndef CONTAINER_TOOL
$(error No container tool (docker, podman) found in your environment. Please, install one)
endif

@echo "Running image with $(CONTAINER_TOOL)"
ifdef DOCKER_CMD
${CONTAINER_TOOL} run --rm -it -p 8080:8080 -v ${PWD}/data:/move2kube-api/data -v /var/run/docker.sock:/var/run/docker.sock quay.io/konveyor/move2kube-ui:latest
else
${CONTAINER_TOOL} run --rm -it -p 8080:8080 --network=bridge quay.io/konveyor/move2kube-ui:latest
endif
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ An UI for interacting with [Move2Kube API](https://github.com/konveyor/move2kube
## Starting the UI

1. Build the UI image: `make cbuild`
2. This uses docker and runs everything inside a single container using the UI image: `make crun`
2. This uses `docker` or `podman` and runs everything inside a single container using the UI image: `make crun`
3. Access the UI at http://localhost:8080

For Helm chart and Operator checkout [Move2Kube Operator](https://github.com/konveyor/move2kube-operator).

## Discussion

- For any questions reach out to us on any of the communication channels given on our website https://move2kube.konveyor.io/.
- For any questions reach out to us on any of the communication channels given on our website https://move2kube.konveyor.io/.