forked from shawnwollenberg/ipfs-metadata
-
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.
First test
- Loading branch information
Showing
9 changed files
with
147 additions
and
2 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,36 @@ | ||
name: build-and-push-container | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: env to be used | ||
required: true | ||
type: choice | ||
options: | ||
- dev | ||
default: dev | ||
|
||
jobs: | ||
build-and-push: | ||
name: build-and-push-container | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: config-aws-credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | ||
- name: login-to-ecr | ||
id: login-to-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
- name: and push docker image to ECR | ||
env: | ||
REGISTRY: ${{ steps.login-to-ecr.outputs.registry }} | ||
REPOSITORY: ipfs-metadata-${{ inputs.environment }} | ||
TAG: ipfs-metadata-${{ github.run_number }} | ||
run: | | ||
docker build -t $REGISTRY/$REPOSITORY:$TAG . | ||
docker push $REGISTRY/$REPOSITORY:$TAG |
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,6 @@ | ||
.env | ||
.env | ||
ipfs_fetcher | ||
# Terraform | ||
.terraform/ | ||
.terraform.* | ||
terraform.tfstate |
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 @@ | ||
FROM golang:1.23-alpine AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod ./ | ||
COPY *.go ./ | ||
|
||
RUN go mod tidy | ||
RUN go build -o /ipfs_fetcher | ||
|
||
## Using a smaller image to run our application | ||
FROM scratch | ||
WORKDIR / | ||
COPY --from=build /ipfs_fetcher /ipfs_fetcher | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/ipfs_fetcher"] |
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,3 @@ | ||
docker-build: | ||
docker build -t ipfs-metadata . | ||
|
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
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,17 @@ | ||
# ipfs-metadata | ||
|
||
## Build and run application | ||
## CI/CD pipeline | ||
|
||
### Requirements | ||
|
||
* Create following AWS variables as secrets in the github repository. | ||
|
||
``` | ||
AWS_ACCESS_KEY_ID | ||
AWS_SECRET_ACCESS_KEY | ||
AWS_DEFAULT_REGION | ||
``` | ||
|
||
## Deploy infrastructure with terraform | ||
## Deploy application |
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,9 @@ | ||
# Infrastructure repo | ||
|
||
Simple repo to keep track of infra changes for the project | ||
|
||
## Prerequisites | ||
|
||
* An IAM user with admin permissions + aws cli access | ||
* Create a bucket for each env (check infrastructure/dev/ecr/providers.tf to find/change the file name) | ||
* Create the DynamoDB table |
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,33 @@ | ||
locals { | ||
service = "ipfs-metadata" | ||
environment = "dev" | ||
} | ||
|
||
module "ecr" { | ||
source = "terraform-aws-modules/ecr/aws" | ||
|
||
repository_name = "${local.service}-${local.environment}" | ||
|
||
repository_lifecycle_policy = jsonencode({ | ||
rules = [ | ||
{ | ||
rulePriority = 1, | ||
description = "Keep last 5 images", | ||
selection = { | ||
tagStatus = "tagged", | ||
tagPrefixList = ["v"], | ||
countType = "imageCountMoreThan", | ||
countNumber = 5 | ||
}, | ||
action = { | ||
type = "expire" | ||
} | ||
} | ||
] | ||
}) | ||
|
||
tags = { | ||
Terraform = "true" | ||
Environment = local.environment | ||
} | ||
} |
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 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
} | ||
|
||
backend "s3" { | ||
region = "us-west-2" | ||
bucket = "ipfs-tfstate-bon4ca" | ||
key = "dev/ecr/terraform.tfstate" | ||
dynamodb_table = "ipfs-tf-tfstate" | ||
encrypt = true | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-west-2" | ||
|
||
default_tags { | ||
tags = { | ||
Application = "ipfs-metadata" | ||
Environment = "dev" | ||
} | ||
} | ||
} |