5분 뒤에 시작하는 React with Docker
Docker 설치
작업 디렉토리 만들기 $ mkdir react-with-docker
$ cd react-with-docker
문서 파일 만들기 $ vi Dockerfile
DockerfileFROM node:14.5.0-alpine
WORKDIR /usr/src/app
※ 기본 인상은 최신이죠.
docker-compose.yml 만들기 $ vi docker-compose.yml
docker-compose.ymlversion: '3'
services:
node:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/usr/src/app # ローカルとコンテナ内の同期
command: sh -c "cd react-sample && yarn start"
ports:
- "3000:3000"
stdin_open: true # https://teratail.com/questions/249875
컨테이너 만들기 $ docker-compose build
React 응용 프로그램 만들기 $ docker-compose run --rm node sh -c "npm install -g create-react-app && create-react-app react-sample"
로컬과 컨테이너 안에 모두 제작된 것을 확인합니다react-sample
!$ ls
$ docker-compose run node ls
시작 컨테이너 $ docker-compose up
액세스 http://localhost:3000/
하면, 만약, 만약...
Hello World!해보다 $ vi react-with-docker/react-sample/src/App.js
App.jsimport React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
+ <p>
+ Hello World!
+ </p>
</header>
</div>
);
}
export default App;
react-with-docker/react-sample/src/App.css
디자인을 바꿔보는 것도 재미있다!
참고 자료
$ mkdir react-with-docker
$ cd react-with-docker
$ vi Dockerfile
DockerfileFROM node:14.5.0-alpine
WORKDIR /usr/src/app
※ 기본 인상은 최신이죠.docker-compose.yml 만들기 $ vi docker-compose.yml
docker-compose.ymlversion: '3'
services:
node:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/usr/src/app # ローカルとコンテナ内の同期
command: sh -c "cd react-sample && yarn start"
ports:
- "3000:3000"
stdin_open: true # https://teratail.com/questions/249875
컨테이너 만들기 $ docker-compose build
React 응용 프로그램 만들기 $ docker-compose run --rm node sh -c "npm install -g create-react-app && create-react-app react-sample"
로컬과 컨테이너 안에 모두 제작된 것을 확인합니다react-sample
!$ ls
$ docker-compose run node ls
시작 컨테이너 $ docker-compose up
액세스 http://localhost:3000/
하면, 만약, 만약...
Hello World!해보다 $ vi react-with-docker/react-sample/src/App.js
App.jsimport React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
+ <p>
+ Hello World!
+ </p>
</header>
</div>
);
}
export default App;
react-with-docker/react-sample/src/App.css
디자인을 바꿔보는 것도 재미있다!
참고 자료
$ vi docker-compose.yml
version: '3'
services:
node:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/usr/src/app # ローカルとコンテナ内の同期
command: sh -c "cd react-sample && yarn start"
ports:
- "3000:3000"
stdin_open: true # https://teratail.com/questions/249875
$ docker-compose build
React 응용 프로그램 만들기 $ docker-compose run --rm node sh -c "npm install -g create-react-app && create-react-app react-sample"
로컬과 컨테이너 안에 모두 제작된 것을 확인합니다react-sample
!$ ls
$ docker-compose run node ls
시작 컨테이너 $ docker-compose up
액세스 http://localhost:3000/
하면, 만약, 만약...
Hello World!해보다 $ vi react-with-docker/react-sample/src/App.js
App.jsimport React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
+ <p>
+ Hello World!
+ </p>
</header>
</div>
);
}
export default App;
react-with-docker/react-sample/src/App.css
디자인을 바꿔보는 것도 재미있다!
참고 자료
$ docker-compose run --rm node sh -c "npm install -g create-react-app && create-react-app react-sample"
$ ls
$ docker-compose run node ls
$ docker-compose up
액세스 http://localhost:3000/하면, 만약, 만약...
Hello World!해보다 $ vi react-with-docker/react-sample/src/App.js
App.jsimport React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
+ <p>
+ Hello World!
+ </p>
</header>
</div>
);
}
export default App;
react-with-docker/react-sample/src/App.css
디자인을 바꿔보는 것도 재미있다!
참고 자료
$ vi react-with-docker/react-sample/src/App.js
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
+ <p>
+ Hello World!
+ </p>
</header>
</div>
);
}
export default App;
Reference
이 문제에 관하여(5분 뒤에 시작하는 React with Docker), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/2754github/items/413bdaaa90834e219dc8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)