Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 7aec421

Browse files
unfor19Meir Gabay
and
Meir Gabay
authored
Feature docker (infracost#47)
* add docker build * add docker pipeline * rm test from docker build * rm golangci Co-authored-by: Meir Gabay <[email protected]>
1 parent c92eccc commit 7aec421

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.*
2+
!.env
3+
Dockerfile
4+
build/
5+
.terraform/
6+
*tfstate*
7+
*.png
8+
*.md
9+
examples/

.github/workflows/docker.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
paths-ignore:
6+
- "README.md"
7+
8+
name: Publish to DockerHub
9+
10+
jobs:
11+
dockerhub:
12+
name: Build and Push to DockerHub
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Build and push Docker images
19+
uses: docker/build-push-action@v1
20+
with:
21+
username: ${{ secrets.DOCKER_USERNAME }}
22+
password: ${{ secrets.DOCKER_PASSWORD }}
23+
repository: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPOSITORY }}
24+
tags: latest
25+
tag_with_sha: true

Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM golang:1.15 as builder
2+
3+
ARG ARCH=linux
4+
ARG TERRAFORM_VERSION=0.12.25
5+
6+
# Set Environment Variables
7+
SHELL ["/bin/bash", "-c"]
8+
ENV HOME /app
9+
ENV CGO_ENABLED 0
10+
ENV GOOS linux
11+
12+
# Install Packages
13+
RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${ARCH}_amd64.zip
14+
RUN apt-get update && apt-get -y install zip -y
15+
RUN unzip terraform*.zip && \
16+
mv terraform /usr/local/bin && \
17+
chmod +x /usr/local/bin/terraform
18+
19+
# Build Application
20+
WORKDIR /app
21+
COPY . .
22+
RUN make deps
23+
RUN make build
24+
25+
# Application
26+
FROM alpine:3.12 as app
27+
ARG TERRAFORM_VERSION=0.12.25
28+
RUN apk --no-cache add ca-certificates terraform=${TERRAFORM_VERSION}-r0
29+
WORKDIR /root/
30+
COPY --from=builder /app/build/infracost /usr/local/bin/infracost
31+
RUN chmod +x /usr/local/bin/infracost
32+
33+
ENTRYPOINT [ "infracost" ]
34+
CMD [ "--help" ]

0 commit comments

Comments
 (0)