Skip to content

Commit

Permalink
improved local dev script
Browse files Browse the repository at this point in the history
  • Loading branch information
bgauduch committed Jul 1, 2023
1 parent 6f126b1 commit fb5844a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ PLATEFORM="linux/$(uname -m)"

# Lint Dockerfile
echo "Linting Dockerfile..."
docker container run --rm --interactive --volume "${PWD}":/data --workdir /data --platform "${PLATEFORM}" hadolint/hadolint:2.12.0-alpine /bin/hadolint --config hadolint.yaml Dockerfile
docker container run --rm --interactive \
--volume "${PWD}":/data \
--workdir /data \
--platform "${PLATEFORM}" \
hadolint/hadolint:2.12.0-alpine /bin/hadolint \
--config hadolint.yaml Dockerfile
echo "Lint Successful!"

# Build image
echo "Building images with AWS_CLI_VERSION=${AWS_VERSION} and TERRAFORM_VERSION=${TF_VERSION}..."
docker buildx build --platform "${PLATEFORM}" --build-arg AWS_CLI_VERSION="${AWS_VERSION}" --build-arg TERRAFORM_VERSION="${TF_VERSION}" --tag ${IMAGE_NAME}:${IMAGE_TAG} .
docker buildx build \
--progress plain \
--platform "${PLATEFORM}" \
--build-arg AWS_CLI_VERSION="${AWS_VERSION}" \
--build-arg TERRAFORM_VERSION="${TF_VERSION}" \
--tag ${IMAGE_NAME}:${IMAGE_TAG} .
echo "Image successfully builded!"

# Test image
Expand All @@ -32,7 +42,12 @@ export AWS_VERSION=${AWS_VERSION} && export TF_VERSION=${TF_VERSION}
envsubst '${AWS_VERSION},${TF_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml
echo "Test config successfully generated!"
echo "Executing container structure test..."
docker container run --rm --interactive --volume "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro --volume /var/run/docker.sock:/var/run/docker.sock:ro gcr.io/gcp-runtimes/container-structure-test:v1.15.0 test --image ${IMAGE_NAME}:${IMAGE_TAG} --config /tests.yml
docker container run --rm --interactive \
--volume "${PWD}"/tests/container-structure-tests.yml:/tests.yml:ro \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
gcr.io/gcp-runtimes/container-structure-test:v1.15.0 test \
--image ${IMAGE_NAME}:${IMAGE_TAG} \
--config /tests.yml

# cleanup
unset AWS_VERSION
Expand Down

0 comments on commit fb5844a

Please sign in to comment.