Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from mercari-build/wknp/run-as-non-root
Browse files Browse the repository at this point in the history
Update Dockerfile to run as non-root user
  • Loading branch information
cocodrips authored Apr 27, 2023
2 parents 17dd942 + d8dbdd0 commit 0b0c30f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions document/08-docker-compose.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In this step, we will learn how to use docker-compose.

**Revisit STEP4 and build a docker image for running the web frontend**

You have a sample `dockerfile` In `typescript/simple-mercari-web`. Modify this file to run frontend on Docker.
You have a sample `Dockerfile` In `typescript/simple-mercari-web`. Modify this file to run frontend on Docker.

* Set the name of the repository as `build2023/web` and tag as `latest`.

Expand Down Expand Up @@ -51,8 +51,8 @@ Set up `docker-compose.yml` under `mercari-build-training-2023/`
Make a new file `docker-compose.yml` considering the following points.

* Docker image to use
* (Option 1: Difficulty ☆) Use `build2022/app:latest` and `build2023/web:latest` made in STEP4 and STEP6-1
* (Option 2: Difficulty ☆☆☆) Build from `{go|python}/dockerfile` and `typescript/simple-mercari-web/dockerfile`
* (Option 1: Difficulty ☆) Use `build2023/app:latest` and `build2023/web:latest` made in STEP4 and STEP6-1
* (Option 2: Difficulty ☆☆☆) Build from `{go|python}/Dockerfile` and `typescript/simple-mercari-web/Dockerfile`
* Port numbers
* API : 9000
* Frontend : 3000
Expand Down
8 changes: 4 additions & 4 deletions document/08-docker-compose.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

**STEP4を思い出しながらフロントエンドの docker image を作成しましょう。**

`typescript/simple-mercari-web`以下にフロントエンド用の `dockerfile` がすでに用意されています。これを変更しフロントエンドが docker 上で立ち上がるようにしましょう。
`typescript/simple-mercari-web`以下にフロントエンド用の `Dockerfile` がすでに用意されています。これを変更しフロントエンドが docker 上で立ち上がるようにしましょう。

* 名前(リポジトリ名)は `build2023/web`, タグは`latest` とします。

`$ docker run -d -p 3000:3000 build2022/web:latest`
`$ docker run -d -p 3000:3000 build2023/web:latest`

を実行し、ブラウザから[http://localhost:3000/](http://localhost:3000/)が正しく開ければ成功です。

Expand Down Expand Up @@ -49,8 +49,8 @@
以下の点を参考にしながら `docker-compose.yml` を作成しましょう。

* 使用する docker image
* (Option 1: 難易度 ☆) STEP4 と STEP6-1 でそれぞれ build した `build2023/app:latest``build2022/web:latest` を使う
* (Option 2: 難易度 ☆☆☆) `{go|python}/dockerfile``typescript/simple-mercari-web/dockerfile` から build するようにする
* (Option 1: 難易度 ☆) STEP4 と STEP6-1 でそれぞれ build した `build2023/app:latest``build2023/web:latest` を使う
* (Option 2: 難易度 ☆☆☆) `{go|python}/Dockerfile``typescript/simple-mercari-web/Dockerfile` から build するようにする
* 使用する port
* API : 9000
* フロントエンド : 3000
Expand Down
5 changes: 5 additions & 0 deletions go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM alpine

RUN addgroup -S mercari && adduser -S trainee -G mercari
# RUN chown -R trainee:mercari /path/to/db

USER trainee

CMD ["go", "version"]
5 changes: 5 additions & 0 deletions python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM alpine

RUN addgroup -S mercari && adduser -S trainee -G mercari
# RUN chown -R trainee:mercari /path/to/db

USER trainee

CMD ["python", "-V"]
7 changes: 7 additions & 0 deletions typescript/simple-mercari-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:16-alpine
WORKDIR /app

RUN addgroup -S mercari && adduser -S trainee -G mercari
USER trainee

CMD ["node", "-v"]
3 changes: 0 additions & 3 deletions typescript/simple-mercari-web/dockerfile

This file was deleted.

0 comments on commit 0b0c30f

Please sign in to comment.