Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: .env for releases #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Development
NODE_ENV=production
NEXT_PUBLIC_WEB_WALLET_URL=https://web-v2.hydrogen.argent47.net
NEXT_PUBLIC_CHAIN_ID=SN_SEPOLIA
4 changes: 4 additions & 0 deletions .env.hydrogen
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Hydrogen
NODE_ENV=production
NEXT_PUBLIC_WEB_WALLET_URL=https://web-v2.hydrogen.argent47.net
NEXT_PUBLIC_CHAIN_ID=SN_SEPOLIA
4 changes: 4 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Main
NODE_ENV=production
NEXT_PUBLIC_WEB_WALLET_URL=https://web.argent.xyz
NEXT_PUBLIC_CHAIN_ID=SN_MAIN
5 changes: 5 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Staging

NODE_ENV=production
NEXT_PUBLIC_WEB_WALLET_URL=https://web-v2.staging.argent47.net
NEXT_PUBLIC_CHAIN_ID=SN_MAIN
62 changes: 62 additions & 0 deletions Jenkinsfile.infra
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
pipeline {
agent {
docker {
image 'hashicorp/terraform:1.9'
args '--entrypoint=""'
}
}

parameters {
credentials(
name: 'AWS_CREDENTIALS',
credentialType: 'com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl',
description: 'AWS Credentials',
required: true
)

choice(name: 'TYPE', choices: ['plan', 'apply'], description: 'Plan or Apply')
}

stages {
stage('Execute Terraform') {
steps {
dir("infrastructure/") {
withFolderProperties {
withCredentials([string(credentialsId: "webwallet-github-token", variable: 'WEBWALLET_GITHUB_TOKEN'),
string(credentialsId: "gsap-npm-token", variable: 'GSAP_NPM_TOKEN')]) {
withAWS(region: "eu-west-1", credentials: '${AWS_CREDENTIALS}', role: "${AWS_INFRA_DEPLOY_ROLE}", roleAccount: "${AWS_INFRA_ACCOUNT_ID}") {
ansiColor('xterm') {
sh "rm -rf .terraform/"
sh "terraform init"
sh "terraform workspace select ${ENVIRONMENT}"
sh "terraform init"
script{

if (params.TYPE == 'plan') {
echo "You selected plan!"
sh """
terraform plan \
-var-file=config/${ENVIRONMENT}.tfvars \
-var 'github_token=$WEBWALLET_GITHUB_TOKEN' \
-var 'gsap_npm_token=$GSAP_NPM_TOKEN'
"""
}
if (params.TYPE == 'apply') {
echo "You selected apply!"
sh """
terraform apply -auto-approve \
-var-file=config/${ENVIRONMENT}.tfvars \
-var 'github_token=$WEBWALLET_GITHUB_TOKEN' \
-var 'gsap_npm_token=$GSAP_NPM_TOKEN'
"""
}
}
}
}
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions infrastructure/.terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.9.2
62 changes: 62 additions & 0 deletions infrastructure/amplify.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
resource "aws_amplify_app" "app" {
name = "demo-dapp-starknet-${var.environment}"
repository = "https://github.com/argentlabs/demo-dapp-starknet"
access_token = var.github_token
platform = "WEB_COMPUTE"

build_spec = <<-EOT
version: 1
frontend:
phases:
preBuild:
commands:
- nvm install $VERSION_NODE_20
- nvm use $VERSION_NODE_20
- corepack enable && corepack enable pnpm
- pnpm config set //npm.greensock.com/:_authToken=$GSAP_NPM_TOKEN
- pnpm install
- pnpm config delete //npm.greensock.com/:_authToken=$GSAP_NPM_TOKEN
build:
commands:
- pnpm build:${var.environment}
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- .next/cache/**/*
EOT


enable_auto_branch_creation = false

environment_variables = merge({
for k, v in {
_CUSTOM_IMAGE = "amplify:al2023",
GSAP_NPM_TOKEN = var.gsap_npm_token,
} : k => v if v != null
})
}

resource "aws_amplify_branch" "branch" {
app_id = aws_amplify_app.app.id
branch_name = var.branch

display_name = terraform.workspace
framework = "Next.js - SSR"

enable_auto_build = true
enable_performance_mode = var.enable_performance_mode
}

resource "aws_amplify_domain_association" "domain_association" {
app_id = aws_amplify_app.app.id
domain_name = "${var.domain_name}"

sub_domain {
branch_name = aws_amplify_branch.branch.branch_name
prefix = "demo-dapp-starknet"
}
}
5 changes: 5 additions & 0 deletions infrastructure/config/dev.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
workspace_iam_role = "arn:aws:iam::694716557937:role/TerraformRole"

branch = "develop"
environment = "dev"
domain_name = "dev.argent47.net"
5 changes: 5 additions & 0 deletions infrastructure/config/hydrogen.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
workspace_iam_role = "arn:aws:iam::551208209252:role/TerraformRole"

branch = "hydrogen"
environment = "hydrogen"
domain_name = "hydrogen.argent47.net"
6 changes: 6 additions & 0 deletions infrastructure/config/prod.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
workspace_iam_role = "arn:aws:iam::372157827898:role/TerraformRole"

branch = "main"
environment = "prod"
domain_name = "argent.xyz"
enable_performance_mode = "true"
5 changes: 5 additions & 0 deletions infrastructure/config/staging.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
workspace_iam_role = "arn:aws:iam::911160948013:role/TerraformRole"

branch = "staging"
environment = "staging"
domain_name = "staging.argent47.net"
50 changes: 50 additions & 0 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
terraform {
required_version = ">= 1.9"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.58"
}
}

backend "s3" {
bucket = "terraform.infra.eu-west-1.argent47.net"
workspace_key_prefix = "workspace-demo-dapp-starknet"
key = "tfstate.json"
dynamodb_table = "argent-infra-terraform"
region = "eu-west-1"
}
}

data "terraform_remote_state" "main" {
backend = "s3"

workspace = terraform.workspace

config = {
bucket = "terraform.infra.eu-west-1.argent47.net"
workspace_key_prefix = "workspace"
key = "tfstate.json"
region = "eu-west-1"
}
}

locals {
environment = terraform.workspace
role = var.workspace_iam_role
}

provider "aws" {
region = "eu-west-1"

assume_role {
role_arn = local.role
}
}

data "aws_vpc" "vpc" {
id = data.terraform_remote_state.main.outputs.vpc_id
}

data "aws_caller_identity" "current" {}
10 changes: 10 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Build variables
variable "workspace_iam_role" {}
variable "environment" {}
variable "branch" {}
variable "domain_name" {}
variable "github_token" {}
variable "gsap_npm_token" {}
variable "enable_performance_mode" {
default = false
}