- ã¯ããã«
- æ¤è¨¼ç°å¢
- ãã£ã¬ã¯ããªæ§æ
- å種è¨å®ãã¡ã¤ã«
- base ã¤ã¡ã¼ã¸ã®ãã«ã
- Amon2 ã®ã¤ã³ã¹ãã¼ã«
- ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ã®ä½æ
- devapp ã¤ã¡ã¼ã¸ã®ãã«ã
- åä½ç¢ºèª
- åèãµã¤ã
ã¯ããã«
以å Docker 㧠Amon2 ã®éçºç°å¢æ§ç¯ã®è¨äºãæ¸ãã¾ããããå½æã¨æ¯è¼ãã¦æ§æãå¤ãã£ã¦ããã®ã§æ¹ãã¦è¨äºã«ã¾ã¨ãã¾ãã
æ¤è¨¼ç°å¢
Windows11 Home Edition (version 23H2) D:\>wsl --version WSL ãã¼ã¸ã§ã³: 2.2.4.0 ã«ã¼ãã« ãã¼ã¸ã§ã³: 5.15.153.1-2 WSLg ãã¼ã¸ã§ã³: 1.0.61 MSRDC ãã¼ã¸ã§ã³: 1.2.5326 Direct3D ãã¼ã¸ã§ã³: 1.611.1-81528511 DXCore ãã¼ã¸ã§ã³: 10.0.26091.1-240325-1447.ge-release Windows ãã¼ã¸ã§ã³: 10.0.22631.3880 # installed ubuntu version Ubuntu 22.04.4 LTS (Jammy Jellyfish) # docker Docker version 25.0.3, build 4debf41 Docker Compose version v2.24.6
ãã£ã¬ã¯ããªæ§æ
amon2 âââ .dockerignore âââ Dockerfile âââ compose.build.yml âââ compose.yml âââ cpanfile
å種è¨å®ãã¡ã¤ã«
amon2/.dockerignore
.git Dockerfile compose.yml compose.build.yml local
amon2/Dockerfile
ãã«ãã¹ãã¼ã¸ãã«ãã§ã¤ã¡ã¼ã¸ãä½æãã¾ã
base
ã§ã¯ Carton ã®ã¤ã³ã¹ãã¼ã«ã¨ã¯ã¼ã¯ãã£ã¬ã¯ããªã®ä½æ
devapp
ã§ã¯ã¤ã¡ã¼ã¸ã¸ã®ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã¨ãã¼ã«ã«ã§ç·¨éããã½ã¼ã¹ã®ã¤ã¡ã¼ã¸ã¸ã®æ¸ãè¾¼ã¿ãè¡ã£ã¦ãã¾ã
FROM perl:5.40 AS base WORKDIR /tmp # install Carton RUN cpanm Carton # create appuser RUN useradd -d /home/appuser -m -s /bin/bash -u 1000 appuser USER 1000 RUN mkdir /home/appuser/app WORKDIR /home/appuser/app FROM base AS devapp USER 1000 COPY cpanfile cpanfile.snapshot /home/appuser/app/ RUN carton install COPY . /home/appuser/app/ EXPOSE 3000 CMD ["carton","exec","--","plackup","-p","3000","-r","myapp/app.psgi"]
amon2/compose.build.yml
base
ã¿ã¼ã²ããããã«ãããããã® compose ãã¡ã¤ã«
ããã§ãã«ãããã¤ã¡ã¼ã¸ã使ã£ã¦ Amon2 ãã¤ã³ã¹ãã¼ã«ãã¾ã
services: base: build: context: . dockerfile: ./Dockerfile target: base image: "takaya030/amon2-base" volumes: - '.:/home/appuser/app'
amon2/compose.yml
devapp
ã¿ã¼ã²ããã®ãã«ãã¨èµ·åã®ããã® compose ãã¡ã¤ã«
Amon2 ãã¤ã³ã¹ãã¼ã«ããå¾ã¯ãã¡ãã使ã£ã¦ã¢ããªã±ã¼ã·ã§ã³ã®ã¤ã¡ã¼ã¸ããã«ããã¾ã
services: devapp: build: context: . dockerfile: ./Dockerfile image: "takaya030/amon2-devapp" volumes: - '.:/home/appuser/app' ports: - "3000:3000" command: ["carton","exec","--","plackup","-p","3000","-r","myapp/app.psgi"]
amon2/cpanfile
requires 'Plack', '1.0051'; requires 'Amon2', '6.16'; requires 'Amon2::Lite', '0.13';
base
ã¤ã¡ã¼ã¸ã®ãã«ã
$ cd amon2 $ docker pull perl:5.40 $ docker compose -f compose.build.yml build base
Amon2 ã®ã¤ã³ã¹ãã¼ã«
base
ã¤ã¡ã¼ã¸ã使ã£ã¦ã¤ã³ã¹ãã¼ã«ãã¾ã
$ docker compose -f compose.build.yml run --rm base carton install
ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ã®ä½æ
$ docker compose -f compose.build.yml run --rm base carton exec -- amon2-setup.pl --flavor=Lite myapp
devapp
ã¤ã¡ã¼ã¸ã®ãã«ã
ãã¡ããã¢ããªã±ã¼ã·ã§ã³ã®ã¤ã¡ã¼ã¸ã¨ãªãã¾ã
$ docker compose build devapp
åä½ç¢ºèª
ãã¹ã¦ã®ãã«ããæåããå ´åã¯ä»¥ä¸ã®ãããª2åã®ã¤ã¡ã¼ã¸ãä½æããã¾ã
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE takaya030/amon2-devapp latest 1bc12fd5ab1c 3 hours ago 1.08GB takaya030/amon2-base latest 1108e2b78874 3 hours ago 1GB
以ä¸ã®ã³ãã³ãã§ã¢ããªã±ã¼ã·ã§ã³ã®ã³ã³ãããèµ·åãã¾ã
$ docker compose up -d
web ãã©ã¦ã¶ã§ http://localhost:3000 ã«ã¢ã¯ã»ã¹ãã¦ä»¥ä¸ã®ç»é¢ã表示ãããã°æåã§ã
ã¢ããªã±ã¼ã·ã§ã³ãåæ¢ããã«ã¯ä¸è¨ã®ã³ãã³ããå ¥åãã¾ã
$ docker compose down