-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLD-8329]Create custom image for atlantis tool to run terraform (#1)
* [CLD-8329]Create custom image for atlantis tool to run terraform * [CLD-8329]Keep atlantis version in makefile only * [CLD-8329]comment trivy block because there's no image in the registry yet * [CLD-8329]uncomment trivy block * [CLD-8329]comment trivy block because there's no image in the registry yet
- Loading branch information
Showing
9 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: docker-build | ||
description: Reusable action to build repos' docker images | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: ci/prepare-docker-environment | ||
uses: ./.github/actions/docker-prepare | ||
|
||
# - name: cd/scan-docker-security | ||
# uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0 | ||
# with: | ||
# image-ref: "mattermost/atlantis" | ||
# format: "table" | ||
# ignore-unfixed: true | ||
# vuln-type: "os,library" | ||
# severity: "CRITICAL" | ||
|
||
- name: cd/push-image-pr | ||
run: "make push-image-pr" | ||
shell: bash | ||
if: github.event_name == 'pull_request' | ||
|
||
- name: cd/push-image | ||
run: "make build" | ||
shell: bash | ||
if: github.event_name != 'pull_request' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: "docker-prepare" | ||
description: "Install docker requirements" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: ci/setup-buildx | ||
uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 | ||
with: | ||
version: v0.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: ci/checkout-repo | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: ci/build-docker | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} | ||
uses: ./.github/actions/docker-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ARG ATLANTIS_VERSION | ||
|
||
FROM ghcr.io/runatlantis/atlantis:${ATLANTIS_VERSION} | ||
|
||
USER root | ||
|
||
RUN apk --no-cache add \ | ||
jq~=1 \ | ||
yq~=4 \ | ||
kubectl~=1 \ | ||
aws-cli \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
USER atlantis | ||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
CMD ["server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ATLANTIS_VERSION ?= v0.27.3 | ||
MATTERMOST_ATLANTIS_IMAGE ?= mattermost/atlantis:test | ||
PLATFORMS ?= linux/amd64,linux/arm64 | ||
MATTERMOST_ATLANTIS_REPO=mattermost/atlantis | ||
|
||
build-image: | ||
@if [ -z "$(DOCKER_USERNAME)" ] || [ -z "$(DOCKER_PASSWORD)" ]; then \ | ||
echo "DOCKER_USERNAME and/or DOCKER_PASSWORD not set. Skipping Docker login."; \ | ||
else \ | ||
echo $(DOCKER_PASSWORD) | docker login --username $(DOCKER_USERNAME) --password-stdin; \ | ||
fi | ||
docker buildx build \ | ||
--build-arg ATLANTIS_VERSION=$(ATLANTIS_VERSION) \ | ||
--platform=$(PLATFORMS) \ | ||
-t $(MATTERMOST_ATLANTIS_IMAGE) \ | ||
--push . | ||
|
||
build-image-with-tag: | ||
@if [ -z "$(DOCKER_USERNAME)" ] || [ -z "$(DOCKER_PASSWORD)" ]; then \ | ||
echo "DOCKER_USERNAME and/or DOCKER_PASSWORD not set. Skipping Docker login."; \ | ||
else \ | ||
echo $(DOCKER_PASSWORD) | docker login --username $(DOCKER_USERNAME) --password-stdin; \ | ||
fi | ||
docker buildx build \ | ||
--build-arg ATLANTIS_VERSION=$(ATLANTIS_VERSION) \ | ||
--platform=$(PLATFORMS) \ | ||
-t $(MATTERMOST_ATLANTIS_IMAGE) \ | ||
-t $(MATTERMOST_ATLANTIS_REPO):${TAG} \ | ||
--push . | ||
|
||
.PHONY: push-image-pr | ||
push-image-pr: | ||
@echo Push Image PR | ||
./scripts/push-image-pr.sh | ||
|
||
.PHONY: push-image | ||
push-image: | ||
@echo Push Image | ||
./scripts/push-image.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# mattermost-atlantis-docker | ||
|
||
This repository contains the necessary files to build a custom Docker image for the [Atlantis](https://github.com/runatlantis/atlantis) tool using Docker Buildx. It supports building multi-platform images and pushing them to Docker Hub. | ||
|
||
## Prerequisites | ||
|
||
Before you begin, ensure you have the following installed: | ||
|
||
- [Docker](https://www.docker.com/) with [Buildx](https://docs.docker.com/buildx/working-with-buildx/) enabled | ||
- Make sure you are logged into Docker Hub or have the credentials available for login | ||
|
||
## Environment Variables | ||
|
||
To push the image to Docker Hub, the following environment variables should be set: | ||
|
||
- `DOCKER_USERNAME`: Your Docker Hub username | ||
- `DOCKER_PASSWORD`: Your Docker Hub password or access token | ||
|
||
## Variables | ||
|
||
The Makefile accepts the following optional variables: | ||
|
||
- `ATLANTIS_VERSION`: The version of Atlantis to include in the Docker image. Defaults to `v0.27.3`. | ||
- `MATTERMOST_ATLANTIS_IMAGE`: The name of the Docker image to build. Defaults to `mattermost/atlantis:test`. | ||
- `PLATFORMS`: The platforms for which to build the image. Defaults to `linux/amd64,linux/arm64`. | ||
- `MATTERMOST_ATLANTIS_REPO`: The Docker repository where the image will be pushed. Defaults to `mattermost/atlantis`. | ||
|
||
## Makefile Targets | ||
|
||
### `build-image` | ||
|
||
This command builds the Docker image and pushes it to the Docker repository specified by `MATTERMOST_ATLANTIS_IMAGE`. | ||
|
||
```bash | ||
make build-image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
|
||
make build-image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ -n "${TAG}" ] | ||
then | ||
echo "Pushing ${TAG} for release ..." | ||
else | ||
echo "Pushing latest for ${GITHUB_REF_NAME} ..." | ||
export TAG="latest" | ||
fi | ||
|
||
make build-image-with-tag |