This file contains hidden or 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
PYENV_PYTHON_VERSION=3.1 | |
brew install pyenv | |
pyenv install $PYENV_PYTHON_VERSION | |
pyenv global $PYENV_PYTHON_VERSION | |
pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc |
This file contains hidden or 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
project_name=dockerized-dotnet | |
init_command="dotnet new webapi -o ${project_name} --no-https" | |
docker_image=mcr.microsoft.com/dotnet/sdk:3.1-alpine | |
docker run --rm -td --name "${project_name}-init" "${docker_image}" sh -c "${init_command} && sleep 60" | |
sleep 20 | |
docker cp ${project_name}-init:/${project_name} . |
This file contains hidden or 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
FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine AS step1 | |
WORKDIR /src | |
COPY dockerized-dotnet.csproj . | |
RUN dotnet restore | |
COPY . . | |
RUN dotnet publish -c release -o /app | |
FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine | |
WORKDIR /app | |
COPY --from=step1 /app . |
This file contains hidden or 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
FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine | |
ENV WORKDIR /app | |
WORKDIR ${WORKDIR} | |
COPY dockerized-dotnet.csproj . | |
RUN dotnet restore | |
COPY . . |
This file contains hidden or 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
build-dev: | |
@docker build -f ./docker/dev/Dockerfile -t dockerized-dotnet:dev . | |
tag=1.0.0 | |
build-prod: | |
@docker build -f ./docker/prod/Dockerfile -t dockerized-dotnet:${tag} . | |
@docker tag dockerized-dotnet:${tag} dockerized-dotnet:latest | |
console: build-dev | |
@docker run --rm -it dockerized-dotnet:dev sh |
This file contains hidden or 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 script tags a untagged ECR Images using its diggest | |
ECR_REPO=my-ecr-repo-name | |
IMAGE_DIGEST="sha256:ab6DSA4f1f940df430062009fdfb02d3ede74b48e39ada939047c2e7d0ee3ac50d8" | |
TAG=my-tag | |
# --- | |
MANIFEST=$(aws ecr batch-get-image --repository-name $ECR_REPO --image-ids imageDigest=$IMAGE_DIGEST --query 'images[].imageManifest' --output text) | |
aws ecr put-image --repository-name $ECR_REPO --image-tag $TAG --image-manifest "$MANIFEST" |
This file contains hidden or 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
""" | |
OAuth2 Device Flow adaptation from Implicit Flow - Useful for CLIs | |
""" | |
from http.server import SimpleHTTPRequestHandler, HTTPServer | |
import os | |
from os.path import expanduser | |
import json | |
callback_html = """ | |
<body style="font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif"> |
This file contains hidden or 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
# Python script to programmatically generate the access token from a service-account key | |
# It does what the following commands does: | |
# - gcloud auth activate-service-account | |
# - gcloud auth print-access-token | |
import google.auth | |
import google.auth.transport.requests | |
from google.oauth2 import service_account | |
from os.path import expanduser |
This file contains hidden or 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
NAMESPACE=apigee | |
kubectl proxy & | |
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize |
This file contains hidden or 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
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) |