Skip to content

Instantly share code, notes, and snippets.

@tseho
tseho / api.mk
Created January 2, 2022 14:45
Deploy serverless
# Build and push the docker image, then deploy a new release of the Cloud Run service
.PHONY: api.deploy
api.deploy:
docker build . -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
gcloud --project $(GCLOUD_PROJECT) run deploy $(GCLOUD_SERVICE) --image $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) --region $(GCLOUD_REGION)
provider "google" {
project = var.gcp_project
region = var.gcp_region
credentials = file(var.gcp_auth_file)
}
data "google_project" "project" {
}
# Docker image registry
@tseho
tseho / Makefile
Last active January 1, 2022 16:40
DOTENV in Makefile
# If there is a .env file, create a temporary copy of it, in a format supported by Makefile
# where every variable become a fallback. "FOO=bar" becomes "FOO?=bar"
ifneq (,$(wildcard ./.env))
DOTENV_PATH=/tmp/$(shell echo $$(pwd) | base64)
include $(shell cat .env | grep -v --perl-regexp '^('$$(env | sed 's/=.*//'g | tr '\n' '|')')\=' | sed 's/=/?=/g' > $(DOTENV_PATH); echo '$(DOTENV_PATH)')
endif
# Expose all defined variables to subprocesses.
export
@tseho
tseho / config.yml
Last active April 5, 2022 20:38
circleci + docker-compose + layers cache
version: 2
jobs:
build:
docker:
- image: docker:17.06.0-ce-git
steps:
- checkout
- setup_remote_docker
- run:
name: Install Docker Compose