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: Don't require the use of docker group #328

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ gpg-preflight:

# --- DOCKER
run: validate-reqs docker-build ## Run the simulator - the build stage of the container runs all the cli tests
@docker run \
@$(DOCKER) run \
-h launch \
-v $(SIMULATOR_AWS_CREDS_PATH):/home/launch/.aws \
-v $(KUBE_SIM_TMP):/home/launch/.kubesim \
Expand All @@ -94,20 +94,20 @@ docker-build-nocache: ## Builds the launch container without the Docker cache
@touch ~/.kubesim/simulator.yaml
@mkdir -p $(SIMULATOR_TFVAR_DIR)
@touch $(SIMULATOR_TFVAR_DIR)/bastion.tfvars
@docker build --no-cache -t $(CONTAINER_NAME_LATEST) .
@$(DOCKER) build --no-cache -t $(CONTAINER_NAME_LATEST) .

.PHONY: docker-build
docker-build: ## Builds the launch container
@mkdir -p ~/.kubesim
@touch ~/.kubesim/simulator.yaml
@mkdir -p $(SIMULATOR_TFVAR_DIR)
@touch $(SIMULATOR_TFVAR_DIR)/bastion.tfvars
@docker build -t $(CONTAINER_NAME_LATEST) .
@$(DOCKER) build -t $(CONTAINER_NAME_LATEST) .

.PHONY: docker-test
docker-test: validate-reqs docker-build ## Run the tests
@export AWS_DEFAULT_REGION="testing propagation to AWS_REGION var"; \
docker run \
$(DOCKER) run \
-v "$(SIMULATOR_AWS_CREDS_PATH)":/home/launch/.aws \
--env-file launch-environment \
--rm -t $(CONTAINER_NAME_LATEST) \
Expand Down Expand Up @@ -175,10 +175,10 @@ release: validate-reqs gpg-preflight previous-tag release-tag docker-test docker
git push origin $(RELEASE_TAG)
hub release create -F $(TMP_FILE) -a dist/simulator -a kubesim $(RELEASE_TAG)
rm -rf $(TMP_FILE)
docker tag $(CONTAINER_NAME_LATEST) $(DOCKER_HUB_ORG)/simulator:$(RELEASE_TAG)
docker push $(DOCKER_HUB_ORG)/simulator:$(RELEASE_TAG)
docker tag $(CONTAINER_NAME_LATEST) $(DOCKER_HUB_ORG)/simulator:latest
docker push $(DOCKER_HUB_ORG)/simulator:latest
$(DOCKER) tag $(CONTAINER_NAME_LATEST) $(DOCKER_HUB_ORG)/simulator:$(RELEASE_TAG)
$(DOCKER) push $(DOCKER_HUB_ORG)/simulator:$(RELEASE_TAG)
$(DOCKER) tag $(CONTAINER_NAME_LATEST) $(DOCKER_HUB_ORG)/simulator:latest
$(DOCKER) push $(DOCKER_HUB_ORG)/simulator:latest
cd attack && RELEASE_TAG=$(RELEASE_TAG) make release


Expand Down
5 changes: 5 additions & 0 deletions prelude.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ GO_LDFLAGS=-ldflags "-w -X $(PKG)/cmd.commit=$(GIT_SHA) -X $(PKG)/cmd.version=$(

GO := go

ifeq ($(shell getent group docker | grep "\b$(USER)\b"),)
DOCKER := sudo docker
else
DOCKER := docker
endif
7 changes: 6 additions & 1 deletion scripts/validate-requirements
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ else
fi

echo -n "Checking Docker is running.."
if getent group docker | grep -q "\b$USER\b"; then
sudoDocker=""
else
sudoDocker="sudo"
fi

if [[ $(docker version) ]]; then
if [[ $($sudoDocker docker version) ]]; then
echo "running"
else
echo "not running"
Expand Down