17
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

docker-composeでreact環境構築(更新版)

Last updated at Posted at 2020-06-14

概要

docker-composeでReact環境構築のnodejs更新版です

ちょっと古いので他の記事参考にした方がいいかもです
更新版までお待ちをです:bow:(2022/12月)

環境

Docker version 19.03.8
docker-compose version 1.25.4

構築作業

Dockerfile作成

Dockerfile
FROM node:12.18.0-alpine
WORKDIR /usr/src/app

docker-compose.yml作成

docker-compose.yml
version: '3'
services:
  react:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
     - ./:/usr/src/app
    command: sh -c "cd workplace && yarn start"
    ports:
     - "3000:3000"
    tty: true

イメージをビルド

$ docker-compose build

React と create-react-app をインストール + アプリ作成

$ docker-compose run --rm react sh -c "npm install -g create-react-app && create-react-app workplace"

↓作成ディレクトリ

- Dockerfile
- docker-compose.yml
- workplace
	|- node_module/
	|- public/
	|- src/
	|- package.json
	|- yarn.lock

起動

前の記事参照でお願いします:bow:

最後に

docker-compose.ymlの内容変えたい...

参考

17
15
2

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
17
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?