This commit is contained in:
parent
4857e68f93
commit
9a3ee9efe3
8
.gitignore
vendored
8
.gitignore
vendored
@ -171,3 +171,11 @@ cython_debug/
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
# terraform.tfstate files
|
||||||
|
_*.tfvars
|
||||||
|
.terraform/
|
||||||
|
.terraform.lock.hcl
|
||||||
|
*.tfstate
|
||||||
|
*.tfstate.backup
|
||||||
|
*deploy.env
|
||||||
57
readme/deploy.md
Normal file
57
readme/deploy.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# デプロイの方法について
|
||||||
|
|
||||||
|
## インストール方法
|
||||||
|
|
||||||
|
MACの場合
|
||||||
|
|
||||||
|
```sh
|
||||||
|
brew tap hashicorp/tap
|
||||||
|
brew install hashicorp/tap/terraform
|
||||||
|
# 確認
|
||||||
|
terraform -version
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 環境について
|
||||||
|
|
||||||
|
* terraform
|
||||||
|
* google cloud
|
||||||
|
* Cloud Fucntions
|
||||||
|
|
||||||
|
## ローカル実行する方法
|
||||||
|
|
||||||
|
ローカルで実行する場合はバックエンドを修正する必要がある
|
||||||
|
`provider.tf`の次の文をコメントアウトする
|
||||||
|
|
||||||
|
```tf
|
||||||
|
terraform {
|
||||||
|
# backend "gcs" {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# 初期化を実行する
|
||||||
|
cd terraform
|
||||||
|
# Terraformの初期化
|
||||||
|
terraform init
|
||||||
|
# デプロイするコンポーネントを確認する
|
||||||
|
terraform plan -var-file=dev.tfvars
|
||||||
|
|
||||||
|
# デプロイを実行する
|
||||||
|
terraform apply \
|
||||||
|
-var-file=dev.tfvars \
|
||||||
|
-auto-approve
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
ローカルでビルドで試す場合
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# デフォルトでビルドする場合
|
||||||
|
docker build -t cloud-run-job-base .
|
||||||
|
# arm64でビルドしたい場合
|
||||||
|
docker buildx build -platform linux/amd64,linux/arm64 -t cloud-run-job-base .
|
||||||
|
# Dockerを実行する(1回だけ実行してコンテナインスタンスを削除する場合)
|
||||||
|
docker run --rm cloud-run-job-base:latest
|
||||||
|
```
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ def main(request: Request):
|
|||||||
# Headerを取得する
|
# Headerを取得する
|
||||||
ua = request.headers.get("User-Agent", "Unknown")
|
ua = request.headers.get("User-Agent", "Unknown")
|
||||||
logger.info(f"User-Agent: {ua}")
|
logger.info(f"User-Agent: {ua}")
|
||||||
|
logger.debug(f"Request Method: {request.method}")
|
||||||
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
logger.info("Processing GET request")
|
logger.info("Processing GET request")
|
||||||
|
|||||||
@ -19,6 +19,10 @@ resource "google_cloudfunctions2_function" "function" {
|
|||||||
object = google_storage_bucket_object.source.name
|
object = google_storage_bucket_object.source.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment_variables = {
|
||||||
|
ENV = var.env_name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service_config {
|
service_config {
|
||||||
@ -28,6 +32,7 @@ resource "google_cloudfunctions2_function" "function" {
|
|||||||
available_memory = var.available_memory
|
available_memory = var.available_memory
|
||||||
|
|
||||||
service_account_email = google_service_account.account.email
|
service_account_email = google_service_account.account.email
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
resource "google_storage_bucket" "bucket" {
|
resource "google_storage_bucket" "bucket" {
|
||||||
provider = google-beta
|
provider = google
|
||||||
name = "${var.component_name}-gcf-source" # Every bucket name must be globally unique
|
name = "${var.component_name}-gcf-source" # Every bucket name must be globally unique
|
||||||
location = var.region
|
location = var.region
|
||||||
uniform_bucket_level_access = true
|
uniform_bucket_level_access = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user