Skip to content

Commit

Permalink
Added Github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PranoSA committed Feb 22, 2024
1 parent 80efa6e commit cae6697
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 7 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/push_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: unicode-docker-repository
run-name: unicode-docker-run
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push default image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: pcadler/unicode-terraform-plugin:latest
target: default

- name: Build and push american image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}/american-latest
target: american

- name: Build and push amphibian image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: pcadler/unicode-terraform-plugin:amphibian-latest
target: amphibian

- name: Build and push halloween image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: pcadler/unicode-terraform-plugin:halloween-latest
target: halloween

#test_docker_build:

#test_apply_and_destroy:

#push_docker_images:
11 changes: 11 additions & 0 deletions .terraformrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
provider_installation {

dev_overrides {
"hashicorp.com/edu/unicode" = "/home/app"
}

# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
65 changes: 65 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Build Out Provider
FROM golang:1.21-alpine AS compiler
WORKDIR /terraform-provider-unicode
COPY . .
#RUN rm $GOPATH/go.mod
RUN go build .
RUN chmod +x terraform-provider-unicode
RUN chown 1000:1000 terraform-provider-unicode
RUN chgrp 1000 terraform-provider-unicode

# Temporary Container TO Build User
FROM debian:stretch-slim as auth
RUN groupadd -g 1000 app && useradd -u 1000 -g 1000 -m app

# Copy Into Terraform Container
FROM hashicorp/terraform:light as default
# Make User 1000
COPY --from=auth /etc/passwd /etc/passwd
COPY --from=auth /etc/group /etc/group
COPY --from=auth /home/app /home/app
RUN chown 1000:1000 /home/app
# Make Home Directory
COPY --from=compiler /terraform-provider-unicode/terraform-provider-unicode /home/app/terraform-provider-unicode
COPY --from=compiler /terraform-provider-unicode/.terraformrc /home/app/.terraformrc
RUN chown 1000:1000 /home/app/.terraformrc
RUN chown 1000:1000 /home/app/terraform-provider-unicode
RUN chmod +x /home/app/terraform-provider-unicode
# Now Switch to User app
USER app
WORKDIR /home/app
ENTRYPOINT ["terraform", "apply", "-auto-approve"]
CMD ["--var", "user=default"]
# does this user follow you arround?

# American App -> Take in variables and output
FROM default as american
USER app
WORKDIR /home/app
RUN mkdir america-themed-app
COPY --from=compiler /terraform-provider-unicode/examples/america-themed_app/ /home/app/america-themed-app
WORKDIR /home/app/america-themed-app
#&& terraform init
ENTRYPOINT [ "terraform", "apply","-auto-approve"]
CMD ["--var", "user=default" ]

FROM default as amphibian
USER app
WORKDIR /home/app
RUN mkdir amphibian-themed-app
COPY --from=compiler /terraform-provider-unicode/examples/amphibian_themed_app/ /home/app/amphibian-themed-app
WORKDIR /home/app/amphibian-themed-app
#&& terraform init
ENTRYPOINT [ "terraform","apply","-auto-approve"]
CMD ["--var", "user=default" ]


FROM default as halloween
USER app
WORKDIR /home/app
RUN mkdir halloween-themed-app
COPY --from=compiler /terraform-provider-unicode/examples/halloween_themed_app/ /home/app/halloween-themed-app
WORKDIR /home/app/halloween-themed-app

ENTRYPOINT [ "terraform", "apply","-auto-approve"]
CMD ["--var", "user=default" ]
8 changes: 4 additions & 4 deletions examples/america-themed_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ resource "unicode_app" "america_application_v2" {
}

resource "unicode_unicode_string" "america_string" {
app_id = unicode_app.ammerica_application_v2.id
app_id = unicode_app.america_application_v2.id
value = "🇺🇸"
}

resource "unicode_unicode_string" "football_string" {
app_id = unicode_app.ammerica_application_v2.id
app_id = unicode_app.america_application_v2.id
value = "🏈"
}

resource "unicode_unicode_string" "baseball_string" {
app_id = unicode_app.ammerica_application_v2.id
app_id = unicode_app.america_application_v2.id
value = ""
}

resource "unicode_unicode_string" "fastfood_string" {
app_id = unicode_app.ammerica_application_v2.id
app_id = unicode_app.america_application_v2.id
value = "🍔🥤🍟🌭"
}
6 changes: 3 additions & 3 deletions examples/amphibian_themed_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ provider "unicode" {
resource "unicode_app" "amphibian_application" {
name = "Amphibian Application"
description = "Amphibian App v2"
id = "1215902212-123091SDSA"
updated_at = "2024-02-07T00:00:00Z"
created_at = "2024-02-07T10:00:00Z"
//id = "1215902212-123091SDSA"
updated_at = "2024-02-07T00:00:00Z"
created_at = "2024-02-07T10:00:00Z"
}

resource "unicode_unicode_string" "frog_string" {
Expand Down

0 comments on commit cae6697

Please sign in to comment.