AWS Finch Docker やり方集


## 注意事項
finch run が出来ることのみ動作確認。実際にmysql login が出来るか等は未確認

## 前提条件
- Homebrew がインストールされていること

## 実行確認済み環境
- OS: macOS Ventura 13.2.1
- Chip: M2 Pro
- RAM: 32 GB
- Finch: v0.4.1

## 導入
### 1. インストール
```bash
brew install --cask finch
```
### 2. Finch 初期化
```bash
finch vm init
```
### 3. Finch 動作確認
```bash
finch run --rm --platform=arm64 public.ecr.aws/finch/hello-finch
```

## Finch 便利コマンド
### Finch キャッシュ削除
```bash
finch system prune -a
```
### ECR Public 認証
1. Finchテンプレートの追記
    ```yaml:~/.finch/finch.yaml
    creds_helpers:
        - ecr-login
    ```
2. Finchコンフィグの追記
    ```json:~/.finch/config.json
    {
        "credsStore": "ecr-login"
    }
    ```
3. Finch VM 再起動
    ```bash
    finch vm stop
    finch vm start
    ```
4. ECR Public 認証
    ```bash
    # リージョンは必ずus-east-1
    ## プロファイル(--profile)いらない場合
    aws ecr-public get-login-password --region us-east-1 | finch login --username AWS --password-stdin public.ecr.aws

    ## プロファイル(--profile)いる場合
    aws ecr-public get-login-password --region us-east-1 --profile xxxxx | finch login --username AWS --password-stdin public.ecr.aws
    ```

## AWS ECR Public
### OS系
#### ● AmazonLinux 2023
```bash
finch run --rm --platform=arm64 public.ecr.aws/amazonlinux/amazonlinux:2.0.20230221.0-arm64v8 uname -ms
```
#### ● Alpine Linux
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/alpine:latest uname -ms
```
#### ● Debian Linux
```bash
finch run --rm --platform=arm64 public.ecr.aws/debian/debian:stable-slim uname -ms
```
#### ● Debian Linux ARM
```bash
finch run --rm --platform=arm64 public.ecr.aws/debian/arm64:stable-slim uname -ms
```
#### ● Ubuntu
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/ubuntu:latest uname -ms
```
#### ● Alma Linux
```bash
finch run --rm --platform=arm64 public.ecr.aws/almalinux/almalinux:latest uname -ms
```
#### ● BottleRocket SDK aarch64
```bash
finch run --rm --platform=arm64 public.ecr.aws/bottlerocket/bottlerocket-sdk-aarch64:v0.30.0 uname -ms
```
### AWS SAM
#### ● SAM Build Python 3.8
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-python3.8:latest uname -ms
```
#### ● SAM Build Python 3.9
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-python3.9:latest uname -ms
```
#### ● SAM Build NodeJS 18.x
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-nodejs18.x:latest uname -ms
```
#### ● SAM Build NodeJS 16.x
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-nodejs16.x:latest uname -ms
```
#### ● SAM Build NodeJS 14.x
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-nodejs14.x:latest uname -ms
```
#### ● SAM Build Java 11
```bash
finch run --rm --platform=arm64 public.ecr.aws/sam/build-java11:latest uname -ms
```
### AWS Resource
#### ● Compose Python 3.9
```bash
finch run --rm --platform=arm64 public.ecr.aws/compose-x/python:3.9 uname -ms
```
#### ● Lambda Python
```bash
finch run --rm --platform=arm64 public.ecr.aws/lambda/python:latest
```
#### ● Lambda NodeJS
```bash
finch run --rm --platform=arm64 public.ecr.aws/lambda/nodejs:latest
```
#### ● Lambda Java
```bash
finch run --rm --platform=arm64 public.ecr.aws/lambda/java:latest
```
#### ● DynamoDB Local
```bash
finch run --rm --platform=arm64 -p 8000:8000 public.ecr.aws/aws-dynamodb-local/aws-dynamodb-local
```
#### ● CodeBuild Local
```bash
finch run --rm --platform=arm64 public.ecr.aws/codebuild/local-builds:latest
```
#### ● LocalStack
```bash
finch run --rm --platform=arm64 public.ecr.aws/localstack/localstack:latest
```
#### ● EC2 MetaData Mock v1.11.2
```bash
finch run --rm --platform=arm64 public.ecr.aws/aws-ec2/amazon-ec2-metadata-mock:v1.11.2
```
### Platform
#### ● NodeJS
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/node:lts-slim node --version
```
#### ● Elasticsearch 8.6.2
```bash
finch run --rm --platform=arm64 -p 9200:9200 -e discovery.type=single-node public.ecr.aws/elastic/elasticsearch:8.6.2
```
#### ● Kibana 8.6.2
```bash
finch run --rm --platform=arm64 public.ecr.aws/elastic/kibana:8.6.2
```
#### ● LogStash 8.6.2
```bash
finch run --rm --platform=arm64 public.ecr.aws/elastic/logstash:8.6.2
```
#### ● FileBeat 8.6.2
```bash
finch run --rm --platform=arm64 public.ecr.aws/elastic/filebeat:8.6.2
```
#### ● Maven
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/maven:amazoncorretto mvn --version
```
#### ● Gradle
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/gradle:latest gradle -v
```
### Programming Language
#### ● Python
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/python:slim python -V
```
#### ● Golang
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/golang:alpine go version
```
#### ● Amazon Corretto JDK 19
```bash
finch run --rm --platform=arm64 public.ecr.aws/amazoncorretto/amazoncorretto:19-al2-jdk java -version
```
#### ● Amazon Corretto JDK 17
```bash
finch run --rm --platform=arm64 public.ecr.aws/amazoncorretto/amazoncorretto:17-al2022-jdk java -version
```
#### ● Amazon Corretto JDK 11
```bash
finch run --rm --platform=arm64 public.ecr.aws/amazoncorretto/amazoncorretto:11-al2022-jdk java -version
```
#### ● Amazon Corretto JDK 8
```bash
finch run --rm --platform=arm64 public.ecr.aws/amazoncorretto/amazoncorretto:8-al2022-jdk java -version
```
### DataBase
#### ● Postgres
```bash
finch run --rm --platform=arm64 -p 8080:8080 -e POSTGRES_PASSWORD=password public.ecr.aws/ubuntu/postgres:latest
```
#### ● MySQL
```bash
finch run --rm --platform=arm64 -p 30306:3306 -e MYSQL_ROOT_PASSWORD=password public.ecr.aws/ubuntu/mysql:latest
```
#### ● Mongo
```bash
finch run --rm --platform=arm64 public.ecr.aws/docker/library/mongo:latest
```
#### ● Maria
```bash
finch run --rm --platform=arm64 -e MARIADB_ROOT_PASSWORD=password public.ecr.aws/docker/library/mariadb:latest
```