Skip to content

Commit

Permalink
Handle spaces in path to Docker command (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Aug 15, 2023
1 parent b1e1c0f commit 777ad50
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: lint

on:
Expand All @@ -14,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: cloudposse/build-harness@1.8.0
- uses: docker://cloudposse/build-harness:latest
with:
entrypoint: /usr/bin/make
args: readme/lint
Expand All @@ -24,9 +25,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Lint Code Base
uses: github/super-linter/slim@v4
uses: github/super-linter/slim@v5
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_NATURAL_LANGUAGE: false
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.4-alpine3.17
FROM golang:1.20.7-alpine3.18
LABEL maintainer="Cloud Posse <[email protected]>"

LABEL "com.github.actions.name"="Build Harness"
Expand Down Expand Up @@ -27,13 +27,13 @@ RUN apk --update --no-cache add \
py3-cffi && \
python3 -m pip install --upgrade pip setuptools wheel && \
pip3 install --no-cache-dir \
cryptography==41.0.2 \
cryptography==41.0.3 \
PyYAML==6.0.1 \
awscli==1.29.9 \
awscli==1.29.25 \
boto==2.49.0 \
boto3==1.28.9 \
boto3==1.28.25 \
iteration-utilities==0.11.0 \
PyGithub==1.59 && \
PyGithub==1.59.1 && \
git config --global advice.detachedHead false

# Install pre-commit support
Expand Down Expand Up @@ -83,7 +83,7 @@ RUN curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/in
COPY <<EOF /root/.tflint.hcl
plugin "aws" {
enabled = true
version = "0.23.0"
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
EOF
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.17
FROM alpine:3.18
LABEL maintainer="Cloud Posse <[email protected]>"

LABEL "com.github.actions.name"="Build Harness"
Expand Down Expand Up @@ -47,7 +47,7 @@ RUN curl -sSL https://raw.githubusercontent.com/terraform-linters/tflint/master/
COPY <<EOF /root/.tflint.hcl
plugin "aws" {
enabled = true
version = "0.23.0"
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
EOF
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Here are some real world examples:
```text
Available targets:

.PHONY Login into docker hub
aws/install Install aws cli bundle
aws/shell Start a aws-vault shell with access to aws api
bash/lint Lint all bash scripts
Expand Down Expand Up @@ -180,7 +181,6 @@ Available targets:
docker/image/promote/local Promote $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/image/promote/remote Pull $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION and promote to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/image/push Push $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/login Login into docker hub
docs/copyright-add Add copyright headers to source code
docs/github-action.md Update `docs/github-action.md` from `action.yaml`
docs/github-actions-reusable-workflows.md Update `docs/github-actions-reusable-workflows.md` from `.github/workflows/*.yaml`
Expand Down
2 changes: 1 addition & 1 deletion docs/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
```text
Available targets:
.PHONY Login into docker hub
aws/install Install aws cli bundle
aws/shell Start a aws-vault shell with access to aws api
bash/lint Lint all bash scripts
Expand Down Expand Up @@ -41,7 +42,6 @@ Available targets:
docker/image/promote/local Promote $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/image/promote/remote Pull $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION and promote to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/image/push Push $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/login Login into docker hub
docs/copyright-add Add copyright headers to source code
docs/github-action.md Update `docs/github-action.md` from `action.yaml`
docs/github-actions-reusable-workflows.md Update `docs/github-actions-reusable-workflows.md` from `.github/workflows/*.yaml`
Expand Down
6 changes: 3 additions & 3 deletions modules/docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DOCKER ?= $(shell which docker)
DOCKER ?= docker

DOCKER_RUN ?= docker run -i --rm --network=$(DOCKER_NETWORK)
DOCKER_EXEC ?= $(DOCKER) exec -it
DOCKER_RUN ?= "$(DOCKER)" run -i --rm --network=$(DOCKER_NETWORK)
DOCKER_EXEC ?= "$(DOCKER)" exec -it
CONTAINER_SHELL ?= sh

# It's like ssh for docker
Expand Down
12 changes: 7 additions & 5 deletions modules/docker/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ DOCKER_BUILD_FLAGS ?= --no-cache
DOCKER_IMAGE_NAME ?= tests
DOCKER_FILE ?= ./Dockerfile

.PHONY: docker/build docker/image/promote/local docker/image/promote/remote docker/image/push

## Build docker image
docker/build: $(DOCKER)
docker/build:
$(call assert-set,DOCKER)
$(call assert-set,DOCKER_IMAGE_NAME)
ifeq ($(TRAVIS),true)
Expand All @@ -16,7 +18,7 @@ endif
printf -- '--build-arg %s=%s ' "$$arg" "$${!arg}"; \
done`; \
echo "Building $(DOCKER_IMAGE_NAME) from $(DOCKER_FILE) with [$(DOCKER_BUILD_FLAGS)] build args..."; \
$(DOCKER) build $(DOCKER_BUILD_FLAGS) $$BUILD_ARGS -t $(DOCKER_IMAGE_NAME) -f $(DOCKER_FILE) $(DOCKER_BUILD_PATH)
"$(DOCKER)" build $(DOCKER_BUILD_FLAGS) $$BUILD_ARGS -t $(DOCKER_IMAGE_NAME) -f $(DOCKER_FILE) $(DOCKER_BUILD_PATH)


## Promote $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
Expand All @@ -27,15 +29,15 @@ docker/image/promote/local:
$(call assert-set,SOURCE_VERSION)
$(call assert-set,TARGET_DOCKER_REGISTRY)
$(call assert-set,TARGET_VERSION)
@$(DOCKER) tag $(SOURCE_DOCKER_REGISTRY)/$(IMAGE_NAME):$(SOURCE_VERSION) $(TARGET_DOCKER_REGISTRY)/$(IMAGE_NAME):$(TARGET_VERSION)
@"$(DOCKER)" tag $(SOURCE_DOCKER_REGISTRY)/$(IMAGE_NAME):$(SOURCE_VERSION) $(TARGET_DOCKER_REGISTRY)/$(IMAGE_NAME):$(TARGET_VERSION)

## Pull $SOURCE_DOCKER_REGISTRY/$IMAGE_NAME:$SOURCE_VERSION and promote to $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
docker/image/promote/remote:
$(call assert-set,DOCKER)
$(call assert-set,IMAGE_NAME)
$(call assert-set,SOURCE_DOCKER_REGISTRY)
$(call assert-set,SOURCE_VERSION)
@$(DOCKER) pull $(SOURCE_DOCKER_REGISTRY)/$(IMAGE_NAME):$(SOURCE_VERSION)
@"$(DOCKER)" pull $(SOURCE_DOCKER_REGISTRY)/$(IMAGE_NAME):$(SOURCE_VERSION)
@$(SELF) -s docker/image/promote/local

## Push $TARGET_DOCKER_REGISTRY/$IMAGE_NAME:$TARGET_VERSION
Expand All @@ -44,4 +46,4 @@ docker/image/push:
$(call assert-set,IMAGE_NAME)
$(call assert-set,TARGET_DOCKER_REGISTRY)
$(call assert-set,TARGET_VERSION)
$(DOCKER) push $(TARGET_DOCKER_REGISTRY)/$(IMAGE_NAME):$(TARGET_VERSION)
"$(DOCKER)" push $(TARGET_DOCKER_REGISTRY)/$(IMAGE_NAME):$(TARGET_VERSION)
8 changes: 5 additions & 3 deletions modules/docker/Makefile.hub
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## Use DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD env variables to pass credentials
## Login into docker hub
docker/login: $(DOCKER)
.PHONY: docker/login

docker/login:
@if [ -n "$(DOCKER_HUB_USERNAME)" ] && [ -n "$(DOCKER_HUB_PASSWORD)" ]; then \
$(DOCKER) login --username="$(DOCKER_HUB_USERNAME)" --password="$(DOCKER_HUB_PASSWORD)"; \
"$(DOCKER)" login --username="$(DOCKER_HUB_USERNAME)" --password="$(DOCKER_HUB_PASSWORD)"; \
else \
echo "Skipping docker:login. Docker credentials (DOCKER_HUB_USERNAME or DOCKER_HUB_PASSWORD) are not set"; \
echo "Skipping docker:login. Docker credentials (DOCKER_HUB_USERNAME or DOCKER_HUB_PASSWORD) are not set"; \
fi;

0 comments on commit 777ad50

Please sign in to comment.