Skip to content

Commit

Permalink
setupjob Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Dec 7, 2020
1 parent 41a9277 commit 33ee4cf
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ jobs:
- name: yamllint
run: make yamllint

setupjob:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: build setupjob image
run: cd deploy/docker/setupjob/ && make build

test:
runs-on: ubuntu-20.04
needs: [markdownlint, shellcheck, yamllint]
Expand Down
30 changes: 30 additions & 0 deletions deploy/docker/setupjob/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM alpine:3

ENV TERRAFORM_VERSION 0.12.25-r0

RUN apk update \
&& apk add --no-cache \
bash \
curl \
jq \
terraform=${TERRAFORM_VERSION} \
# ping group has a conflicting id: 999 so delete it
&& delgroup ping \
&& addgroup -g 999 setup \
&& adduser -u 999 -D -G setup setup \
&& mkdir /terraform /scripts \
&& chown -R setup:setup /terraform /scripts

# main.tf is copied from ../../helm/sumologic/conf/setup/setup.sh to minimize
# docker context just to current directory
COPY --chown=setup:setup ./main.tf /terraform/

USER setup
RUN cd /terraform/ \
&& terraform init \
&& rm main.tf

ARG BUILD_TAG=latest
ENV TAG $BUILD_TAG

WORKDIR /terraform/
20 changes: 20 additions & 0 deletions deploy/docker/setupjob/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BUILD_TAG ?= latest
IMAGE_NAME = setupjob
ECR_URL = public.ecr.aws/u5z5f8z6
REPO_URL = $(ECR_URL)/$(IMAGE_NAME)

build:
DOCKER_BUILDKIT=1 docker build \
--build-arg BUILD_TAG=$(BUILD_TAG) \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $(REPO_URL):latest \
--tag $(IMAGE_NAME):$(BUILD_TAG) \
.

push:
docker tag $(IMAGE_NAME):$(BUILD_TAG) $(REPO_URL):$(BUILD_TAG)
docker push $(REPO_URL):$(BUILD_TAG)

login:
aws ecr-public get-login-password --region us-east-1 \
| docker login --username AWS --password-stdin $(ECR_URL)
6 changes: 6 additions & 0 deletions deploy/docker/setupjob/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
terraform {
required_providers {
sumologic = "~> 2.4"
kubernetes = "~> 1.13.0"
}
}

0 comments on commit 33ee4cf

Please sign in to comment.