diff --git a/02-atmos/.dockerignore b/.dockerignore similarity index 94% rename from 02-atmos/.dockerignore rename to .dockerignore index c9b4a04..1006d15 100644 --- a/02-atmos/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ + # Things that could be checked into Git but need not be in the Docker image .git .editorconfig @@ -11,6 +12,7 @@ aws-assumed-role/ # Compiled and auto-generated files **/nohup.out +**/.terraform/* **/*.tfstate **/*.tfstate.* **/planfile @@ -21,7 +23,6 @@ aws-assumed-role/ **/*.terraform.tfvars.json **/*.terraform.auto.tfvars.json **/*.helmfile.vars.yaml -**/vendir.lock.yml # Module directory **/.terraform/ @@ -32,7 +33,6 @@ aws-assumed-role/ # Draft or auto-saved version # Note that the leading "**/" appears necessary for Docker even if not for Git **/*.draft.* -**/*.draft **/*.orig **/*.bak **/*~ @@ -41,4 +41,4 @@ aws-assumed-role/ **/.DS_Store **/.CFUserTextEncoding **/.Trash/ -**/$RECYCLE.BIN/ +**/$RECYCLE.BIN/ \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6fb56c7 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,51 @@ +name: "docker" +on: + pull_request: + types: [opened, synchronize, reopened] + release: + types: + # "released" excludes pre-releases + # "published" is either a release or a pre-release + - published +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout source code at current commit + uses: actions/checkout@v2 + + # Based off of Geodesic docker workflow: + # https://github.com/cloudposse/geodesic/blob/master/.github/workflows/docker.yml + - name: Prepare tags for Docker image + id: prepare + run: | + echo ::set-output name=publish::${{ (github.event_name == 'release' && github.event.action == 'published') || (github.event.pull_request.head.repo.full_name == github.repository) }} + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + fi + + # By default, we tag our image with the short sha on all PR pushes + TAGS="${{ github.repository }}:sha-${GITHUB_SHA:0:7}" + + # If this is a tagged release, then we tag w/ the semver tag + latest + if [[ -n $VERSION ]]; then + TAGS="$TAGS,${{ github.repository }}:${VERSION},${{ github.repository }}:latest" + fi + + printf "Tagging with %s\n" "${TAGS}" + echo "::set-output name=tags::${TAGS}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + if: steps.prepare.outputs.publish == 'true' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: "Build and push docker image to DockerHub" + id: docker_build + uses: docker/build-push-action@v2 + with: + push: ${{ steps.prepare.outputs.publish == 'true' }} + tags: ${{ steps.prepare.outputs.tags }} + file: ./Dockerfile diff --git a/02-atmos/Dockerfile b/02-atmos/Dockerfile deleted file mode 100644 index d57f917..0000000 --- a/02-atmos/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -ARG VERSION=latest -ARG OS=alpine -ARG CLI_NAME=atmos - -FROM cloudposse/geodesic:$VERSION-$OS - -# Geodesic message of the Day -ENV MOTD_URL="https://geodesic.sh/motd" - -ENV DOCKER_IMAGE="cloudposse/atmos" -ENV DOCKER_TAG="latest" - -# Geodesic banner -ENV BANNER="Atmos Tutorial" - -# Install terraform. -RUN apk add -u terraform-0.14@cloudposse -# Set Terraform 0.14.x as the default `terraform`. -RUN update-alternatives --set terraform /usr/share/terraform/0.14/bin/terraform - -# Install Atmos -RUN apk add atmos@cloudposse - -COPY components/ /components/ -COPY stacks/ /stacks/ - -WORKDIR / diff --git a/02-atmos/Makefile b/02-atmos/Makefile deleted file mode 100644 index 84a6151..0000000 --- a/02-atmos/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -export DOCKER_ORG ?= cloudposse -export DOCKER_IMAGE ?= $(DOCKER_ORG)/atmos -export DOCKER_TAG ?= latest -export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) - --include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) - -## Initialize build-harness, install deps, build docker container, install wrapper script and run shell -all: init deps build run - @exit 0 - -## Install dependencies (if any) -deps: - @exit 0 - -## Build docker image -build: - @make --no-print-directory docker/build - -run: - @docker run -it \ - --rm \ - --volume "$$HOME":/localhost \ - --volume "$$PWD"/stacks:/stacks \ - --volume "$$PWD"/components:/components \ - cloudposse/atmos:latest;