こちらからDocker Desktop on Macをインストールします。
※ M1MacやM2Macだったら、Docker Desktop for Mac with Apple silicon
の方をインストールします。
インストールできたら、Docker Desktop on Macを起動します。
$ forkして自分のアカウントのリポジトリにコピーします.
github上でforkボタンを押して、フォークしてください。
$ git clone [email protected]:[自分のアカウント名]/twitter-clone.git
$ cd twitter
$ cp .env.example .env
Docker で環境を立ち上げる
// docker-compose.ymlファイルのある階層に移動します。
$ docker-compose build
$ docker-compose up -d
色々インストールする
$ docker exec -it twitter-clone-app-1 /bin/bash
$ composer install
$ npm install
これで、一通りの環境が立ち上がります。
http://localhost:8083/でLaravelが立ち上がります。
docker container は次の 3 つが立ち上がります。
コンテナ名 | メモ |
---|---|
twitter-clone-app-1 | アプリケーションのコンテナです。 コンテナに入れば php artisan コマンドが使えます。 |
twitter-clone-db-1 | Mysql のインスタンス。 コンテナに入ればMysqlコマンドを使えます。 |
twitter-clone-nginx-1 | Nginx のインスタンス。 |
コマンド | 説明 |
---|---|
docker-compose build | 各コンテナのDockerfileに従ってDocker イメージがビルドされます。 |
docker-compose up -d | 各コンテナを起動するコマンドです。 |
docker-compose down | コンテナを停止するコマンドです。 |
docker exec -it twitter-clone-app-1 /bin/bash | appコンテナに入る |