LoginSignup
0
0

More than 1 year has passed since last update.

DockerでAmplifyCLIを動かす

Posted at

概要

  • Local開発環境を汚したくないのでDocker環境を作る
  • Amplifyの使い方自体は紹介しません

tree

.
├── aws_configure
│   ├── config
│   └── credentials
├── docker
│   ├── Dockerfile
│   └── requirements.txt
├── src
│   ├── amplify
│   └── src
├── docker-compose.yml
└── .gitignore

Dockerfile

FROM python:3.8-buster

RUN apt update && apt -y upgrade \
&& apt install -y nodejs npm \
&& npm install -g @aws-amplify/cli

# java for Amplify Mock
RUN wget -O- https://apt.corretto.aws/corretto.key | apt-key add -
RUN apt install -y software-properties-common \
&& add-apt-repository --yes 'deb https://apt.corretto.aws stable main' \
&& apt -y update && apt install -y java-11-amazon-corretto-jdk

# COPY docker/requirements.txt /tmp/
# RUN pip install --upgrade pip && pip install -r /tmp/requirements.txt

amplify mockを使用するため、Javaをインストールしています
pythonで使いたいパッケージがあれば docker/requirements.txt を用意して最後2行のコメントアウトを外してください

参考
* Amazon Corretto 11 のインストール手順 -AWS Doc
* Install the Amplify CLI
* はじめての Amplify デプロイまで -Qiita
* Ubuntu Linuxで、add-apt-repositoryしようとして「コマンドがない」って言われたら

docker-compose.yml

version: '3'
services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: amplifyApp
    volumes:
      - ./src:/var/app
      - ./aws_configure:/root/.aws
    working_dir: /var/app
    tty: true

ソースコード置き場と、aws設定ファイル置き場をvolumesに設定します
aws_configure 以下のファイルは、amplify init すると作成されます
チーム開発など、設定ファイルがすでにある場合はここに保存しておきます
aws_configure/credentials はcommitすると大変まずいので、.gitignore で除外しましょう

起動

docker compose build
docker compose up -d
docker exec -it amplify-fastapi /bin/bash
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0