Slide 1

Slide 1 text

Docker / ES2015 sandbox 2018.8.3 Hamamatsu.js #4 @jacoyutorius ͱΓ͋͑ͣDockerͰWebαʔόʔΛཱͯͯjsΛॻ͍ͯΈΔ

Slide 2

Slide 2 text

Yuto Ogi FOURIER.Inc Ruby, Rails, Javascript, Vue.js, AWS Hamamatsu.rb JAWS-UG Hamamatsu @jacoyutoirus

Slide 3

Slide 3 text

Contents ES2015ͷ৽ػೳΛࢼ͢؀ڥΛDockerͰ࡞Δ

Slide 4

Slide 4 text

Contents Docker v18.06 / Kitematic Editor

Slide 5

Slide 5 text

Purpose खܰʹWebαʔόʔΛཱ͍ͯͨ ϩʔΧϧʹΠϯετʔϧͨ͠Webαʔόʔ͸ઃఆมߋ͕໘౗ Ծ૝Ϛγϯ͸ىಈ͕஗͍ ͦΖͦΖDocker͍ͬͱ͔͘ɾɾɾ .htmlϑΝΠϧΛ௚ʹ։͘ͱCORSͷ੍ݶʹҾ͔͔ͬΔ

Slide 6

Slide 6 text

Dockerfile FROM nginx MAINTAINER jacoyutorius USER root RUN apt-get update

Slide 7

Slide 7 text

docker-compose ෳ਺ͷ%PDLFSΠϝʔδΛҰׅ؅ཧͰ͖Δɻ

Slide 8

Slide 8 text

docker-compose version: "3" services: webserver: build: context: "./" image: nginx ports: - "5000:80"

Slide 9

Slide 9 text

docker-compose up $ docker-compose up Creating network "hmjs4_default" with the default driver Creating hmjs4_webserver_1 ... done Attaching to hmjs4_webserver_1 webserver_1 | 172.22.0.1 - - [02/Aug/2018:14:01:33 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Kitematic/0.13.0 Chrome/ 45.0.2454.85 Electron/0.35.4 Safari/537.36" "-" webserver_1 | 172.22.0.1 - - [02/Aug/2018:14:01:34 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/ 537.36" "-" webserver_1 | 2018/08/02 14:01:35 [error] 8#8: *2 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.22.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost: 5500", referrer: "http://localhost:5500/" webserver_1 | 172.22.0.1 - - [02/Aug/2018:14:01:35 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http:// localhost:5500/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" "-"

Slide 10

Slide 10 text

Kitematic

Slide 11

Slide 11 text

localhost:5000

Slide 12

Slide 12 text

docker-compose up -d %BFNPOϞʔυɻόοΫάϥ΢ϯυͰ%PDLFS͕ىಈ͢Δɻ

Slide 13

Slide 13 text

docker-compose exec EPDLFSDPNQPTFFYFDXFCTFSWFSCJOCBTI ·ͨ͸ɺ

Slide 14

Slide 14 text

html/index.html

Hello!

Slide 15

Slide 15 text

docker-compose up version: "3" services: webserver: build: context: "./" image: nginx volumes: - “./html:/usr/share/nginx/html” ports: - "5000:80"

Slide 16

Slide 16 text

localhost:5000

Slide 17

Slide 17 text

html/js/script.js window.onload = () => { const p = document.createElement("p") p.innerText = "How are you?" document.body.appendChild(p) }

Slide 18

Slide 18 text

html/index.html

Hello!

Slide 19

Slide 19 text

localhost:5000

Slide 20

Slide 20 text

html/js/modules/greet.js export default (name) => { return `How are you? ${name}` }

Slide 21

Slide 21 text

html/js/script.js import greet from “/js/libs/greet.js" window.onload = () => { const p = document.createElement("p") p.innerText = greet("yuto") document.body.appendChild(p) }

Slide 22

Slide 22 text

localhost:5000

Slide 23

Slide 23 text

tree . ᵓᴷᴷ Dockerfile ᵓᴷᴷ docker-compose.yml ᵋᴷᴷ html ᵓᴷᴷ index.html ᵋᴷᴷ js ᵓᴷᴷ libs ᴹ ᵋᴷᴷ greet.js ᵋᴷᴷ script.js

Slide 24

Slide 24 text

ES2015 Arrow Function String literal module

Slide 25

Slide 25 text

end Arrow Function String literal module