æ¤è¨¼ç°å¢
Windows11 Home Edition (version 23H2) D:\>wsl --version WSL ãã¼ã¸ã§ã³: 2.1.5.0 ã«ã¼ãã« ãã¼ã¸ã§ã³: 5.15.146.1-2 WSLg ãã¼ã¸ã§ã³: 1.0.60 MSRDC ãã¼ã¸ã§ã³: 1.2.5105 Direct3D ãã¼ã¸ã§ã³: 1.611.1-81528511 DXCore ãã¼ã¸ã§ã³: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows ãã¼ã¸ã§ã³: 10.0.22631.3296 # installed ubuntu version Ubuntu 22.04.4 LTS (Jammy Jellyfish) # docker Docker version 25.0.3, build 4debf41 Docker Compose version v2.24.6
Dockerfileãdocker-compose.yml ã®ä½æ
WSL ä¸ã® Linux ã«ãã°ã¤ã³ãã¦ä¸è¨ã³ãã³ããå®è¡
$ mkdir react_example $ cd react_example $ touch Dockerfile docker-compose.yml
åãã¡ã¤ã«ãä¸è¨å 容ã«å¤æ´
Dockerfile
FROM node:18.20.0-alpine WORKDIR /usr/src/app
docker-compose.yml
version: '3' services: node: image: takaya030/node:18-alpine build: . volumes: - ./:/usr/src/app command: sh -c 'cd react-app && yarn start' ports: - '3000:3000'
ReactãTypeScript ã®ã¤ã³ã¹ãã¼ã«
ä¸è¨ã³ãã³ããå®è¡ãã¦ã¤ã³ã¹ãã¼ã«ãã
$ docker compose run --rm node sh -c 'npx create-react-app react-app --template typescript'
react-app
ãã©ã«ããä½æããã
React ã¢ããªã®èµ·å
ä¸è¨ã³ãã³ããå®è¡ãã¦ã³ã³ãããèµ·å
$ docker compose up -d
ã³ã³ããèµ·åå¾ãWEB ãã©ã¦ã¶ã§ http://localhost:3000 ã«ã¢ã¯ã»ã¹ãã¦ä»¥ä¸ã®ç»é¢ã表示ãããã°æå