diff --git a/README.md b/README.md index 5f70d0483..28fbcf5de 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Build@Mercari Training Program 2022 +# Build@Mercari Training Program 2023 This is @'s build training repository. @@ -23,16 +23,19 @@ The following icons indicate pointers for ## Tasks -- [ ] **STEP1** Git ([JA](document/step1.ja.md)/[EN](document/step1.en.md)) -- [ ] **STEP2** Setup environment ([JA](document/step2.ja.md) - /[EN](document/step2.en.md)) -- [ ] **STEP3** Develop API ([JA](document/step3.ja.md) - /[EN](document/step3.en.md)) -- [ ] **STEP4** Docker ([JA](document/step4.ja.md)/[EN](document/step4.en.md)) -- [ ] **STEP5** (Stretch) Frontend ([JA](document/step5.ja.md) - /[EN](document/step5.en.md)) -- [ ] **STEP6** (Stretch) Run on docker-compose ([JA](document/step6.ja.md) - /[EN](document/step6.en.md)) +- [ ] **STEP1** Git ([JA](document/01-git.ja.md)/[EN](document/01-git.en.md)) +- [ ] **STEP2** Setup environment ([JA](document/02-local-env.ja.md) + /[EN](document/02-local-env.en.md)) +- [ ] **STEP3** Develop API ([JA](document/03-api.ja.md) + /[EN](document/03-api.en.md)) +- [ ] **STEP4** Database ([JA](document/04-database.ja.md)/[EN](document/04-database.en.md)) +- [ ] **STEP5** Docker ([JA](document/05-docker.ja.md)/[EN](document/05-docker.en.md)) +- [ ] **STEP6** Continuous Integration(CI) ([JA](document/06-ci.ja.md) + /[EN](document/06-ci.en.md)) +- [ ] **STEP7** (Stretch) Frontend ([JA](document/07-frontend.ja.md) + /[EN](document/07-frontend.en.md)) +- [ ] **STEP8** (Stretch) Run on docker-compose ([JA](document/08-docker-compose.ja.md) + /[EN](document/08-docker-compose.en.md)) ### Other documents diff --git a/data/workflow-enable.png b/data/workflow-enable.png new file mode 100644 index 000000000..ab6e51afd Binary files /dev/null and b/data/workflow-enable.png differ diff --git a/document/step1.en.md b/document/01-git.en.md similarity index 72% rename from document/step1.en.md rename to document/01-git.en.md index c0cdbd3b2..916709aea 100644 --- a/document/step1.en.md +++ b/document/01-git.en.md @@ -3,14 +3,19 @@ In this step, we will learn how to use Git and Github. **:book: Reference** -* [Git basics](https://www.atlassian.com/git) -* [GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://www.udemy.com/course/github-ultimate/) +* (JA)[Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/) +* (JA)[Udemy Business - Git:はじめてのGitとGitHub](https://mercari.udemy.com/course/intro_git/) -## Fork this **mercari-build-training-2022** repository +* (EN)[Git basics](https://www.atlassian.com/git) +* (EN)[Udemy Business - GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://mercari.udemy.com/course/github-ultimate/) -* Fork [mercari-build-training-2022](https://github.com/mercari-build/mercari-build-training-2022) -* You will see be able to see `https://github.com//mercari-build-training-2022` if successful. + + +## Fork this **mercari-build-training-2023** repository + +* Fork [mercari-build-training-2023](https://github.com/mercari-build/mercari-build-training-2023) +* You will see be able to see `https://github.com//mercari-build-training-2023` if successful. ## Install Git @@ -30,24 +35,24 @@ In this step, we will learn how to use Git and Github. ## Use basic commands in Git -1. **Clone** `https://github.com//mercari-build-training-2022` onto your local using the following command. +1. **Clone** `https://github.com//mercari-build-training-2023` onto your local using the following command. ```shell $ cd - $ git clone https://github.com//mercari-build-training-2022 + $ git clone https://github.com//mercari-build-training-2023 ``` **:bangbang: Caution** Please definitely run the following command after cloning repository. ``` -cd mercari-build-training-2022 +cd mercari-build-training-2023 git config --local core.hooksPath .githooks/ ``` -This is required to use githooks in mercari-build-training-2022 repository. +This is required to use githooks in mercari-build-training-2023 repository. 2. Make a new branch named `first-pull-request` and **checkout** into this branch ```shell - $ cd /mercari-build-training-2022 + $ cd /mercari-build-training-2023 $ git branch first-pull-request $ git checkout first-pull-request ``` @@ -90,4 +95,4 @@ Check if you understand the following concepts. ### Next -[STEP2: Building local environmentSTEP2: Building local environment](step2.en.md) +[STEP2: Building local environment](02-local-env.en.md) diff --git a/document/step1.ja.md b/document/01-git.ja.md similarity index 80% rename from document/step1.ja.md rename to document/01-git.ja.md index f36ac8a14..ba9d953ed 100644 --- a/document/step1.ja.md +++ b/document/01-git.ja.md @@ -3,14 +3,17 @@ このステップではGitとGithubの使い方を学びます。 **:book: Reference** -* [Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/) -* [Udemy - Git & Github基礎講座](https://www.udemy.com/course/git-github-a/) -## **mercari-build-training-2022** リポジトリをフォークする +* (JA)[Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/) +* (JA)[Udemy Business - Git:はじめてのGitとGitHub](https://mercari.udemy.com/course/intro_git/) -* [mercari-build-training-2022](https://github.com/mercari-build/mercari-build-training-2022) +* (EN)[Git basics](https://www.atlassian.com/git) +* (EN)[Udemy Business - GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://mercari.udemy.com/course/github-ultimate/) +## **mercari-build-training-2023** リポジトリをフォークする + +* [mercari-build-training-2023](https://github.com/mercari-build/mercari-build-training-2023) をあなたのGithubにForkします。 -* Forkに成功すると `https://github.com//mercari-build-training-2022` +* Forkに成功すると `https://github.com//mercari-build-training-2023` というようなリポジトリができます。 ## Gitをインストールする @@ -30,25 +33,25 @@ ## Gitの基本コマンドを使う -1. `https://github.com//mercari-build-training-2022` を **clone** +1. `https://github.com//mercari-build-training-2023` を **clone** します。 cloneすると、github上のリポジトリを自分のローカルにDownloadできます。 ```shell $ cd - $ git clone https://github.com//mercari-build-training-2022 + $ git clone https://github.com//mercari-build-training-2023 ``` **:bangbang: 注意** cloneができたら必ず以下のコマンドを実行してください。 ```shell -$ cd mercari-build-training-2022 +$ cd mercari-build-training-2023 $ git config --local core.hooksPath .githooks/ ``` これは mercari-build-training-2022 が githooks という機能を使うために必要なものです。 2. `first-pull-request`というブランチを作り、そのブランチに**checkout**します ```shell - $ cd /mercari-build-training-2022 + $ cd /mercari-build-training-2023 $ git branch first-pull-request $ git checkout first-pull-request ``` @@ -90,4 +93,4 @@ $ git config --local core.hooksPath .githooks/ --- ### Next -[STEP2: 環境構築](step2.ja.md) \ No newline at end of file +[STEP2: 環境構築](02-local-env.ja.md) \ No newline at end of file diff --git a/document/step2.en.md b/document/02-local-env.en.md similarity index 77% rename from document/step2.en.md rename to document/02-local-env.en.md index 255908a67..76eabb041 100644 --- a/document/step2.en.md +++ b/document/02-local-env.en.md @@ -67,7 +67,7 @@ If the version does not correspond to the Python version you installed, double c ### 3. Install dependencies -In Go, dependent libraries are managed in a file called `go.mod`. +In Go, dependent libraries are managed in a file called `go.mod`. You can install the dependencies by running the following command. ```shell @@ -97,12 +97,16 @@ If successful, you can access the local host `http://127.0.0.1:9000` on our brow The following resources are useful to dive deeper into building environments and Linux. -* [An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics) -* [Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://www.udemy.com/course/linux-mastery/) +* (JA)[book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R) +* (JA)[Udemy Business - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://mercari.udemy.com/course/linux100test/) + * ↑わかりやすい講座だと思い貼ってますが、コマンドの暗記は特にしなくていいです + +* (EN)[An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics) +* (EN)[Udemy Business - Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://mercari.udemy.com/course/linux-mastery/) * You do NOT have to memorize the commands! --- ### Next -[STEP3: Make a listing API](step3.en.md) \ No newline at end of file +[STEP3: Make a listing API](03-api.en.md) \ No newline at end of file diff --git a/document/step2.ja.md b/document/02-local-env.ja.md similarity index 83% rename from document/step2.ja.md rename to document/02-local-env.ja.md index 74b21fae2..607f6eeee 100644 --- a/document/step2.ja.md +++ b/document/02-local-env.ja.md @@ -99,11 +99,15 @@ $ go run app/main.go 環境構築の仕方やlinuxについてさらにしっかり学ぶためには以下の教材がおすすめです。 -* [book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R) -* [Udemy - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://www.udemy.com/course/linux100test/) +* (JA)[book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R) +* (JA)[Udemy Business - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://mercari.udemy.com/course/linux100test/) * ↑わかりやすい講座だと思い貼ってますが、コマンドの暗記は特にしなくていいです +* (EN)[An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics) +* (EN)[Udemy Business - Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://mercari.udemy.com/course/linux-mastery/) + * You do NOT have to memorize the commands! + --- ### Next -[STEP3: 出品APIを作る](step3.ja.md) \ No newline at end of file +[STEP3: 出品APIを作る](03-api.ja.md) \ No newline at end of file diff --git a/document/step3.en.md b/document/03-api.en.md similarity index 56% rename from document/step3.en.md rename to document/03-api.en.md index f12a81e93..59cf64a9a 100644 --- a/document/step3.en.md +++ b/document/03-api.en.md @@ -4,12 +4,12 @@ **:book: Reference** -* (JA) [Udemy -【基礎からわかる!】Webアプリケーションの仕組み](https://www.udemy.com/course/tobach_01_webapp_structure/) +* (JA) [Udemy Business - REST WebAPI サービス 設計](https://mercari.udemy.com/course/rest-webapi-development/) * (JA) [HTTP レスポンスステータスコード](https://developer.mozilla.org/ja/docs/Web/HTTP/Status) * (JA) [HTTP リクエストメソッド](https://developer.mozilla.org/ja/docs/Web/HTTP/Methods) * (JA) [APIとは?意味やメリット、使い方を世界一わかりやすく解説](https://www.sejuku.net/blog/7087) -* (EN) [API and Web Service Introduction](https://www.udemy.com/course/api-and-web-service-introduction/) +* (EN) [Udemy Business - API and Web Service Introduction](https://mercari.udemy.com/course/api-and-web-service-introduction/) * (EN) [HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) * (EN) [HTTP request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) @@ -91,49 +91,13 @@ $ curl -X GET 'http://127.0.0.1:9000/items' {"items": [{"name": "jacket", "category": "fashion"}, ...]} ``` -## 4. Write into a database - -In the previous step, we saved data into `items.json`. We will move this into a database. -We will use a database called **SQLite**. - -**:book: Reference** - -* (JA)[SQLite入門](https://www.dbonline.jp/sqlite/) -* (JA)[Udemy -【SQLiteで学ぶ】ゼロから始めるデータベースとSQL超入門](https://www.udemy.com/course/basic_database_sqlite/) -* (JA)[Udemy - はじめてのSQLserver データベース SQL未経験者〜初心者向けコース](https://www.udemy.com/course/sqlserver-for-beginner/) -* (EN)[https://www.sqlitetutorial.net/](https://www.sqlitetutorial.net/) -* (EN)[Udemy - Intro To SQLite Databases for Python Programming](https://www.udemy.com/course/using-sqlite3-databases-with-python/) - -Install SQlite, and make a database file called `mercari.sqlite3`. Open this file and make a table called `items`. Define the items table as follows and save the schema into `db/items.db`. - -* id: int (Identifier unique for each item) -* name: string (Name of the item) -* category: string (Category of the item) - -Change the endpoints `GET /items` and `POST /items` such that items are saved into the database and can be returned based on GET request. Add `mercari.sqlite3` to your `.gitignore` such that it is not commited. `items.db` shoud be commited. - -**:beginner: Points** - -* What are the advantages of saving into a databse such as SQLite instead of saving into a single JSON file? - -## 5. Search for an item - -Make an endpoint to return a list of items that include a specified keyword called `GET /search`. - -```shell -# Request a list of items containing string "jacket" -$ curl -X GET 'http://127.0.0.1:9000/search?keyword=jacket' -# Expected response for a list of items with name containing "jacket" -{"items": [{"name": "jacket", "category": "fashion"}, ...]} -``` - -## 6. Add an image to an item +## 4. Add an image to an item Change the endpoints `GET /items` and `POST /items` such that items can have images while listing. * Make a directory called `images` * Hash the image using sha256, and save it with the name `.jpg` -* Modify items table such that the image file can be saved as a string +* Modify items such that the image file can be saved as a string ```shell # POST the jpg file @@ -144,13 +108,10 @@ curl -X POST \ -F 'image=@images/local_image.jpg' ``` +```json +{"items": [{"name": "jacket", "category": "fashion", "image_filename": "510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg"}, ...]} +``` -Items table example: - -| id | name | category | image_filename | -| :--- | :----- | :------- | :------------------------------------------------------------------- | -| 1 | jacket | fashion | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | -| 2 | ... | | | **:beginner: Point** @@ -158,7 +119,7 @@ Items table example: * What other hashing functions are out there except for sha256? -## 7. Return item details +## 5. Return item details Make an endpoint `GET /items/` to return item details. @@ -167,29 +128,7 @@ $ curl -X GET 'http://127.0.0.1:9000/items/1' {"name": "jacket", "category": "fashion", "image": "..."} ``` -## 8. (Optional) Move the category information to a separate table - -Modify the database as follows. This allows changes in the category names and you will not have to change all categories in the items table when they do. Since `GET items` should still return the name of the category, join these two tables when returning responses. - -**items table** - -| id | name | category_id | image_filename | -| :--- | :----- | :---------- | :------------------------------------------------------------------- | -| 1 | jacket | 1 | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | -| 2 | ... | | | - -**category table** - -| id | name | -| :--- | :------ | -| 1 | fashion | -| ... | | - -**:beginner: Points** -* What is database **normalization**? - - -## 9. (Optional) Understand Loggers +## 6. (Optional) Understand Loggers Open `http://127.0.0.1:9000/image/no_image.jpg` on your browser. This returns an image called `no image` but the debug log is not displayed on your console. ``` @@ -215,4 +154,4 @@ Check if you understand the following concepts. ### Next -[STEP4: Run the application in a virtual environment](step4.en.md) \ No newline at end of file +[STEP4: Database](04-database.en.md) diff --git a/document/step3.ja.md b/document/03-api.ja.md similarity index 57% rename from document/step3.ja.md rename to document/03-api.ja.md index 8b0a68887..39d70c424 100644 --- a/document/step3.ja.md +++ b/document/03-api.ja.md @@ -4,12 +4,12 @@ **:book: Reference** -* (JA) [Udemy -【基礎からわかる!】Webアプリケーションの仕組み](https://www.udemy.com/course/tobach_01_webapp_structure/) +* (JA) [Udemy Business - REST WebAPI サービス 設計](https://mercari.udemy.com/course/rest-webapi-development/) * (JA) [HTTP レスポンスステータスコード](https://developer.mozilla.org/ja/docs/Web/HTTP/Status) * (JA) [HTTP リクエストメソッド](https://developer.mozilla.org/ja/docs/Web/HTTP/Methods) * (JA) [APIとは?意味やメリット、使い方を世界一わかりやすく解説](https://www.sejuku.net/blog/7087) -* (EN) [API and Web Service Introduction](https://www.udemy.com/course/api-and-web-service-introduction/) +* (EN) [Udemy Business - API and Web Service Introduction](https://mercari.udemy.com/course/api-and-web-service-introduction/) * (EN) [HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) * (EN) [HTTP request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) @@ -94,54 +94,14 @@ $ curl -X GET 'http://127.0.0.1:9000/items' {"items": [{"name": "jacket", "category": "fashion"}, ...]} ``` -## 4. Databaseに保存する -ここまで`items.json`に情報を保存してきましたが、このデータをデータベースに移し替えます。 -今回は **SQLite**というデータベースを使います。 - -**:book: Reference** - -* (JA)[SQLite入門](https://www.dbonline.jp/sqlite/) -* (JA)[Udemy -【SQLiteで学ぶ】ゼロから始めるデータベースとSQL超入門](https://www.udemy.com/course/basic_database_sqlite/) -* (JA)[Udemy - はじめてのSQLserver データベース SQL未経験者〜初心者向けコース](https://www.udemy.com/course/sqlserver-for-beginner/) -* (EN)[https://www.sqlitetutorial.net/](https://www.sqlitetutorial.net/) -* (EN)[Udemy - Intro To SQLite Databases for Python Programming](https://www.udemy.com/course/using-sqlite3-databases-with-python/) - -SQLiteをインストールし、dbフォルダに、`mercari.sqlite3` というデータベースファイルを作成します。 -`mercari.sqlite3`を開き、`items`テーブルを作成します。 - -itemsテーブルは以下のように定義し、スキーマを `db/items.db` に保存します。 - -* id: int 商品ごとにユニークなID -* name: string 商品の名前 -* category: string 商品のカテゴリ - -データがデータベースに保存され、商品一覧情報を取り出すことができるように、`GET /items`と`POST /items`のエンドポイントを変更しましょう。 - -`items.db`はgitの管理対象にしますが、`mercari.sqlite3`はgitの管理対象として追加しないようにしてください。 - -**:beginner: Point** - -* jsonファイルではなくデータベース(SQLite)にデータを保存する利点は何がありますか? - -## 5. 商品を検索する - -指定したキーワードを含む商品一覧を返す、`GET /search`エンドポイントを作ります。 - -```shell -# "jacket"という文字を含む商品一覧をリクエストする -$ curl -X GET 'http://127.0.0.1:9000/search?keyword=jacket' -# "jacket"をnameに含む商品一覧が返ってくる -{"items": [{"name": "jacket", "category": "fashion"}, ...]} -``` - -## 6. 画像を登録する +## 4. 画像を登録する 商品情報に画像(image)を登録できるように、`GET /items`と`POST /items`のエンドポイントを変更します。 * 画像は `images` というフォルダを作成し保存します -* ポストされた画像のファイル名を sha256 で hash化し、`.jpg`という名前で保存します -* itemsテーブルに画像のファイル名をstringで保存できるように変更を加えます +* ポストされた画像のファイルを sha256 で hash化し、`.jpg`という名前で保存します +* itemsに画像のファイル名をstringで保存できるように変更を加えます ```shell # ローカルから.jpgをポストする @@ -153,19 +113,17 @@ curl -X POST \ ``` -Items table example: +```json +{"items": [{"name": "jacket", "category": "fashion", "image_filename": "510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg"}, ...]} +``` -| id | name | category | image_filename | -| :--- | :----- | :------- | :------------------------------------------------------------------- | -| 1 | jacket | fashion | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | -| 2 | ... | | | **:beginner: Point** * Hash化とはなにか? * sha256以外にどんなハッシュ関数があるか調べてみましょう -## 7. 商品の詳細を返す +## 5. 商品の詳細を返す 商品の詳細情報を取得する `GET /items/` というエンドポイントを作成します。 @@ -174,31 +132,7 @@ $ curl -X GET 'http://127.0.0.1:9000/items/1' {"name": "jacket", "category": "fashion", "image_filename": "..."} ``` -## 8. (Optional) カテゴリの情報を別のテーブルに移す - -データベースを以下のように構成しなおします。 -これによってカテゴリの名前が途中で変わったとしても、全部のitemsテーブルのcategoryを修正する必要がなくなります。 -`GET items`ではcategoryの名前を変わらず取得したいので、テーブルをjoinしてレスポンス用のデータを作って返しましょう。 - -**items table** - -| id | name | category_id | image_filename | -| :--- | :----- | :---------- | :------------------------------------------------------------------- | -| 1 | jacket | 1 | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | -| 2 | ... | | | - -**category table** - -| id | name | -| :--- | :------ | -| 1 | fashion | -| ... | | - -**:beginner: Point** -* データベースの**正規化**とは何でしょうか? - - -## 9. (Optional) Loggerについて調べる +## 6. (Optional) Loggerについて調べる `http://127.0.0.1:9000/image/no_image.jpg`にアクセスしてみましょう。 `no image`という画像が帰ってきますが、 コード中にある ``` @@ -206,7 +140,7 @@ Image not found: ``` というデバッグログがコンソールに表示されません。 これはなぜか、調べてみましょう。 -これを表示するためには、どこを変更したらいいでしょうか? +これを表示するためには、コードのどこを変更したらいいでしょうか? **:beginner: Point** * Log levelとは? @@ -226,4 +160,4 @@ Image not found: ### Next -[STEP4: 仮想環境でアプリを動かす](step4.ja.md) +[STEP5: データベース](04-database.ja.md) diff --git a/document/04-database.en.md b/document/04-database.en.md new file mode 100644 index 000000000..88b334b51 --- /dev/null +++ b/document/04-database.en.md @@ -0,0 +1,68 @@ +# STEP4: Database +In the previous step, we saved data into `items.json`. We will move this into a database. + +**:book: Reference** + +* (JA)[SQLite入門](https://www.dbonline.jp/sqlite/) +* (JA)[Udemy Business - データベース講座1:データベース論理設計](https://mercari.udemy.com/course/database-logic/) + +* (EN)[https://www.sqlitetutorial.net/](https://www.sqlitetutorial.net/) +* (EN)[Udemy Business - SQLite for beginners](https://mercari.udemy.com/course/sqlite-for-beginners/) +* (EN)[Udemy Business - Relational Database Designs](https://mercari.udemy.com/course/relational-database-design/) +## 1. Write into a database +We will use a database called **SQLite**. + +* Install SQlite, and make a database file called `mercari.sqlite3`. +* Open this file and make a table called `items`. +* Define the items table as follows and save the schema into `db/items.db`. + * id: int (Identifier unique for each item) + * name: string (Name of the item) + * category: string (Category of the item) + * image_name: string (Filename of the imeage) + +Change the endpoints `GET /items` and `POST /items` such that items are saved into the database and can be returned based on GET request. Add `mercari.sqlite3` to your `.gitignore` such that it is not commited. `items.db` shoud be commited. + +**:beginner: Points** + +* What are the advantages of saving into a database such as SQLite instead of saving into a single JSON file? + +## 2. Search for an item + +Make an endpoint to return a list of items that include a specified keyword called `GET /search`. + +```shell +# Request a list of items containing string "jacket" +$ curl -X GET 'http://127.0.0.1:9000/search?keyword=jacket' +# Expected response for a list of items with name containing "jacket" +{"items": [{"name": "jacket", "category": "fashion"}, ...]} +``` + +## 8. Move the category information to a separate table + +Modify the database as follows. That makes it possible to change the category names without modifying the all categories of items in the items table. +Since `GET items` should return the category name as before, **join** these two tables when returning responses. + +**items table** + +| id | name | category_id | image_filename | +| :--- | :----- | :---------- | :------------------------------------------------------------------- | +| 1 | jacket | 1 | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | +| 2 | ... | | | + +**category table** + +| id | name | +| :--- | :------ | +| 1 | fashion | +| ... | | + +**:beginner: Points** +* What is database **normalization**? + + + +--- + +### Next + +[STEP5: Run the application in a virtual environment](05-docker.en.md) \ No newline at end of file diff --git a/document/04-database.ja.md b/document/04-database.ja.md new file mode 100644 index 000000000..be1b6c4a6 --- /dev/null +++ b/document/04-database.ja.md @@ -0,0 +1,81 @@ +# STEP4: データベース + +ここまで`items.json`に情報を保存してきましたが、このデータをデータベースに移し替えます。 + +**:book: Reference** + +* (JA)[SQLite入門](https://www.dbonline.jp/sqlite/) +* (JA)[Udemy Business - データベース講座1:データベース論理設計](https://mercari.udemy.com/course/database-logic/) + +* (EN)[https://www.sqlitetutorial.net/](https://www.sqlitetutorial.net/) +* (EN)[Udemy Business - SQLite for beginners](https://mercari.udemy.com/course/sqlite-for-beginners/) +* (EN)[Udemy Business - Relational Database Designs](https://mercari.udemy.com/course/relational-database-design/) + +## 1. SQLiteに情報を移行する +今回は **SQLite**というデータベースを使います。 + +* SQLiteをインストール +* dbフォルダに、`mercari.sqlite3` というデータベースファイルを作成 +* `mercari.sqlite3`を開き、`items`テーブルを作成 +* `items`テーブルは以下のように定義し、スキーマを `db/items.db` に保存します。 + * id: int 商品ごとにユニークなID + * name: string 商品の名前 + * category: string 商品のカテゴリ + * image_name: string 画像のパス + +`items.db`はgitの管理対象にしますが、`mercari.sqlite3`はgitの管理対象として追加しないようにしてください。 + +データがデータベースに保存され、商品一覧情報を取り出すことができるように、`GET /items`と`POST /items`のエンドポイントを変更しましょう。 + + +Items table example: + +| id | name | category | image_name | +| :--- | :----- | :------- |:---------------------------------------------------------------------| +| 1 | jacket | fashion | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | +| 2 | ... | | | + + +**:beginner: Point** + +* jsonファイルではなくデータベース(SQLite)にデータを保存する利点は何がありますか? + +## 2. 商品を検索する + +指定したキーワードを含む商品一覧を返す、`GET /search`エンドポイントを作ります。 + +```shell +# "jacket"という文字を含む商品一覧をリクエストする +$ curl -X GET 'http://127.0.0.1:9000/search?keyword=jacket' +# "jacket"をnameに含む商品一覧が返ってくる +{"items": [{"name": "jacket", "category": "fashion"}, ...]} +``` + +## 3. カテゴリの情報を別のテーブルに移す + +データベースを以下のように構成しなおします。 +これによってカテゴリの名前を途中で変えたとしても、全部のitemsテーブルのcategoryを修正する必要がなくなります。 +`GET items`ではこれまでと同様にcategoryの名前を取得したいので、テーブルを**join**してレスポンス用のデータを作って返すように実装を更新しましょう。 + +**items table** + +| id | name | category_id | image_filename | +| :--- | :----- | :---------- | :------------------------------------------------------------------- | +| 1 | jacket | 1 | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg | +| 2 | ... | | | + +**category table** + +| id | name | +| :--- | :------ | +| 1 | fashion | +| ... | | + +**:beginner: Point** +* データベースの**正規化**とは何でしょうか? + +--- + +### Next + +[STEP5: 仮想環境でアプリを動かす](05-docker.ja.md) diff --git a/document/step4.en.md b/document/05-docker.en.md similarity index 82% rename from document/step4.en.md rename to document/05-docker.en.md index 640d24ae8..168033b67 100644 --- a/document/step4.en.md +++ b/document/05-docker.en.md @@ -1,11 +1,14 @@ -# STEP4: Run the application in a virtual environment +# STEP5: Run the application in a virtual environment In this step, we will learn how to use Docker. **:book: Reference** -* [docker docs](https://docs.docker.com/get-started/overview/) -* [Udemy - ゼロからはじめる Dockerによるアプリケーション実行環境構築](https://www.udemy.com/course/docker-k/) +* (JA)[docker docs](https://matsuand.github.io/docs.docker.jp.onthefly/get-started/overview/) +* (JA)[Udemy Business - ゼロからはじめる Dockerによるアプリケーション実行環境構築](https://mercari.udemy.com/course/docker-k/) + +* (EN)[docker docs](https://docs.docker.com/get-started/overview/) +* (EN)[Udemy Business - Docker for the Absolute Beginner - Hands On - DevOps](https://mercari.udemy.com/course/learn-docker/) ## 1. Install Docker **Install docker of the latest version, and check if you can run `docker -v`.** @@ -16,7 +19,7 @@ In this step, we will learn how to use Docker. ## 2. Run Docker commands -**Make sure that you're in `mercari-build-training-2022/` directory, and run the following command.** +**Make sure that you're in `mercari-build-training-2023/` directory, and run the following command.** ```shell $ docker run -v $(pwd)/data/text_en.png:/tmp/img.png wakanapo/tesseract-ocr tesseract /tmp/img.png stdout -l eng @@ -95,9 +98,9 @@ ERRO[0000] error waiting for container: context canceled `"python"` part will be replaced with `"go"` if you're using Go. -**Modify the `dockerfile` so that you can use the same version of Python/Go as STEP2 in your docker image.** +**Modify the `Dockerfile` so that you can use the same version of Python/Go as STEP2 in your docker image.** -Run the image with the modified `dockerfile`, check if the same message is displayed as STEP2-2. +Run the image with the modified `Dockerfile`, check if the same message is displayed as STEP2-2. **:book: Reference** @@ -130,4 +133,4 @@ Make sure you understand the following concepts ### Next -[STEP5: Implement a simple Mercari webapp as frontend](step5.en.md) \ No newline at end of file +[STEP5: Implement a simple Mercari webapp as frontend](07-frontend.en.md) \ No newline at end of file diff --git a/document/step4.ja.md b/document/05-docker.ja.md similarity index 85% rename from document/step4.ja.md rename to document/05-docker.ja.md index 0039e22b7..615fee42a 100644 --- a/document/step4.ja.md +++ b/document/05-docker.ja.md @@ -1,12 +1,14 @@ -# STEP4: 仮想環境でアプリを動かす +# STEP5: 仮想環境でアプリを動かす このステップでは docker の使い方を学びます。 **:book: Reference** -* [docker docs](https://matsuand.github.io/docs.docker.jp.onthefly/get-started/overview/) -* [Udemy - ゼロからはじめる Dockerによるアプリケーション実行環境構築](https://www.udemy.com/course/docker-k/) +* (JA)[docker docs](https://matsuand.github.io/docs.docker.jp.onthefly/get-started/overview/) +* (JA)[Udemy Business - ゼロからはじめる Dockerによるアプリケーション実行環境構築](https://mercari.udemy.com/course/docker-k/) +* (EN)[docker docs](https://docs.docker.com/get-started/overview/) +* (EN)[Udemy Business - Docker for the Absolute Beginner - Hands On - DevOps](https://mercari.udemy.com/course/learn-docker/) ## 1. Docker をインストールする **最新のdockerをインストールし、`docker -v` が実行できることを確認しましょう。** @@ -74,11 +76,11 @@ docker はホスト上に存在しないイメージを使う際には、自動 ## 4. Docker Image を Build する -**pythonで開発をしている人は`python/`, Goの人は`go/`以下にある`dockerfile`をbuildしてみましょう。** +**pythonで開発をしている人は`python/`, Goの人は`go/`以下にある`Dockerfile`をbuildしてみましょう。** -* 名前(リポジトリ名)は `build2022/app`, タグは`latest` とします。 +* 名前(リポジトリ名)は `build2023/app`, タグは`latest` とします。 -イメージ一覧の中に `build2022/app` という image があれば成功です。 +イメージ一覧の中に `build2023/app` という image があれば成功です。 **:book: Reference** @@ -91,7 +93,7 @@ docker はホスト上に存在しないイメージを使う際には、自動 ``` docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknown. ERRO[0000] error waiting for container: context canceled -``` +``` Goの場合は、上のエラーメッセージの`"python"`の部分が`"go"`になります。 @@ -110,7 +112,7 @@ STEP4-5 までで docker image の中は STEP2-2 と同じ状態になってい **`dockerfile`を変更し、必要なファイルをコピーしたり依存ライブラリをインストールしたりして, docker image 上で 出品 API が動くようにしましょう。** -`$ docker run -d -p 9000:9000 build2022/app:latest` +`$ docker run -d -p 9000:9000 build2023/app:latest` を実行しSTEP3と同様にしてAPIを叩ければ成功です。 @@ -129,4 +131,4 @@ STEP4-5 までで docker image の中は STEP2-2 と同じ状態になってい ### Next -[STEP5: Webのフロントエンドを実装する](step5.ja.md) \ No newline at end of file +[STEP5: Webのフロントエンドを実装する](07-frontend.ja.md) \ No newline at end of file diff --git a/document/06-ci.en.md b/document/06-ci.en.md new file mode 100644 index 000000000..906bea0df --- /dev/null +++ b/document/06-ci.en.md @@ -0,0 +1,43 @@ +# STEP6: Build Docker image using CI + +In this step you will learn how to use CI. + +**:book: Reference** + +* (JA)[継続的インテグレーションについて](https://docs.github.com/ja/actions/automating-builds-and-tests/about-continuous-integration) +* (JA)[Udemy Business - 【新UI対応】Amazon ECS × GitHub Actionsで始めるコンテナベースのアプリケーション開発](https://mercari.udemy.com/course/ecs-githubactions/) + * You can ignore the lectures about Amazon ECS + +* (EN)[About continuous integration](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration) +* (EN)[Udemy Business - The Complete GitHub Actions & Workflows Guide](https://mercari.udemy.com/course/github-actions/) +## 1. About CI +CI is an abbreviation for Continuous Integration. +A process that automatically builds, tests, and more every time you push or merge code. +There are many people who do not have the opportunity to use CI if they are developing alone. + +First learn more about CI by looking into the Reference and Udemy page. + +## 2. Enable Github Actions +Github offers a CI service called Github Actions. +First, enable Github Actions on your repository. + +- [Enable Workflow](https://docs.github.com/en/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) + +After enabling Workflow, create an commit and confirm that the Github Actions Workflow works, by pushing to the repository as a trigger. +The workflow works if :white_check_mark: or :red_circle: is displayed next to the commit comment as shown in the figure below. +![Enable workflow](../data/workflow-enable.png) + +## 3. Build the application with Github Actions and upload the docker image to the registry +The file `.github/workflows/build.yml` already contains a workflow that pushes your code to the registry, + +```yaml +# - name: Build and push Docker image +``` + +Remove the comment out from the Step and push the docker image via CI. + +If the Workflow is successful, the generated image will be pushed to the URL: `ghcr.io//mercari-build-training-2023:`. +Pull the image locally and run it. + +Reference +- [Publishing and installing a package with GitHub Actions](https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token) diff --git a/document/06-ci.ja.md b/document/06-ci.ja.md new file mode 100644 index 000000000..80d09734f --- /dev/null +++ b/document/06-ci.ja.md @@ -0,0 +1,41 @@ +# STEP6: CIを使ってDocker imageをBuildする + +このステップでは CI の使い方を学びます。 +**:book: Reference** + +* (JA)[継続的インテグレーションについて](https://docs.github.com/ja/actions/automating-builds-and-tests/about-continuous-integration) +* (JA)[Udemy Business - 【新UI対応】Amazon ECS × GitHub Actionsで始めるコンテナベースのアプリケーション開発](https://mercari.udemy.com/course/ecs-githubactions/) + * Amazon ECSのパートは飛ばして大丈夫です + +* (EN)[About continuous integration](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration) +* (EN)[Udemy Business - The Complete GitHub Actions & Workflows Guide](https://mercari.udemy.com/course/github-actions/) +## 1. CIを理解する +CIとはContinuous Integration(継続的インテグレーション)の略語で、 +コードをpushしたりmergeしたりするたびに自動的にビルドやテストなどを行うプロセスです。 +一人で開発していると使う機会がない方も多いと思います。 + +まずはReferenceにあるページやUdemyを参考に、CIについて勉強しましょう。 + +## 2. Github Actionsを有効にする +GithubはGithub Actionsと呼ばれるCIサービスを提供しています。 +まずは皆さんのリポジトリでGithub Actionを有効化します。 + +- [ワークフローの有効化](https://docs.github.com/ja/actions/managing-workflow-runs/disabling-and-enabling-a-workflow) + +有効にしたら、適当なcommitを作成し、PushをトリガーにGithub Actionsのワークフローが動くことを確認します。 +以下の図のように:white_check_mark:や:red_circle:がcommit commentの横に表示されていれば動いています。 +![Enable workflow](../data/workflow-enable.png) + +## 3. アプリケーションをGithubActionsでビルドして、docker imageをregistryにupする +`.github/workflows/build.yml`にregistryにあなたのコードをpushするフローが書かれているので、 + +```yaml +# - name: Build and push Docker image +``` +のStepのコメントアウトを外し、CI経由でdocker imageをpushさせてみましょう。 + +うまくいくと `ghcr.io//mercari-build-training-2023:` +というURLにimageがpushされるので、ローカルでそのimageをpullして実行してみましょう。 + +Reference +- [GitHub Actionsでのパッケージの公開とインストール](https://docs.github.com/ja/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token) diff --git a/document/step5.en.md b/document/07-frontend.en.md similarity index 93% rename from document/step5.en.md rename to document/07-frontend.en.md index 1bba5e963..40bdeda4a 100644 --- a/document/step5.en.md +++ b/document/07-frontend.en.md @@ -1,4 +1,4 @@ -# STEP5: Implement a simple Mercari webapp as frontend +# STEP7: Implement a simple Mercari webapp as frontend ## 1. Build local environment @@ -26,7 +26,7 @@ Run the backend servers in Python/Go as described in Step3. This simple web application allows you to do two things - Add a new item (Listing) - View the list of itemas (ItemList) - + These functionalities are carved out as components called `src/components/Listing` and `src/components/ItemList`, and called from the main `App.tsx`. :pushpin: Sample code is in React but the knowledge of React is not necessary. @@ -37,7 +37,7 @@ Use the listing form to add a new item. In this screen, you can input name, cate If your API from STEP3 only accepts name and category, modify `typescript/simple-mercari-web/src/components/Listing/Listing.tsx` and delete the image field. -### (Optional) Task 2. Show item images +### (Optional) Task 2. Show item images In this screen, item images are all rendered as Build@Mercari logo. Specify the item image as `http://localhost:9000/image/.jpg` and see if they can be displayed on the web app. @@ -74,4 +74,4 @@ Current `ItemList` shows one column of items sequentially. Use the following ref ### Next -[STEP6: Run frontend and API using docker-compose](step6.en.md) \ No newline at end of file +[STEP6: Run frontend and API using docker-compose](08-docker-compose.en.md) \ No newline at end of file diff --git a/document/step5.ja.md b/document/07-frontend.ja.md similarity index 97% rename from document/step5.ja.md rename to document/07-frontend.ja.md index 5b1a71176..7d69d853b 100644 --- a/document/step5.ja.md +++ b/document/07-frontend.ja.md @@ -1,4 +1,4 @@ -# STEP5: Webのフロントエンドを実装する +# STEP7: Webのフロントエンドを実装する ## 1. 環境構築 以下からv16のNodeをインストールしてください。 @@ -70,4 +70,4 @@ CSSだけではなく、各コンポーネントでreturnされているHTMLタ ### Next -[STEP6: docker-composeでAPIとフロントエンドを動かす](step6.ja.md) \ No newline at end of file +[STEP6: docker-composeでAPIとフロントエンドを動かす](08-docker-compose.ja.md) \ No newline at end of file diff --git a/document/step6.en.md b/document/08-docker-compose.en.md similarity index 69% rename from document/step6.en.md rename to document/08-docker-compose.en.md index 2c986f109..e46bb0ab1 100644 --- a/document/step6.en.md +++ b/document/08-docker-compose.en.md @@ -1,22 +1,25 @@ -# STEP6: Run frontend and API using docker-compose +# STEP8: Run frontend and API using docker-compose In this step, we will learn how to use docker-compose. **:book: Reference** -* [Docker Compose Overview](https://docs.docker.com/compose/) -* [Udemy - Hands on With Docker & Docker Compose From a Docker Captain](https://www.udemy.com/course/hands-on-with-docker-and-docker-compose/) +* (JA)[Docker Compose の概要](https://matsuand.github.io/docs.docker.jp.onthefly/compose/) +* (JA)[Udemy Business - 駆け出しエンジニアのためのDocker入門](https://mercari.udemy.com/course/docker-startup/) + +* (EN)[Docker Compose Overview](https://docs.docker.com/compose/) +* (EN)[Udemy Business - Docker for the Absolute Beginner - Hands On - DevOps](https://mercari.udemy.com/course/learn-docker/) ## 1. (Revision) Building Docker Images **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 `build2022/web` and tag as `latest`. +* Set the name of the repository as `build2023/web` and tag as `latest`. Run the following and check if you can successfully open [http://localhost:3000/](http://localhost:3000/) on your browser. -`$ docker run -d -p 3000:3000 build2022/web:latest` +`$ docker run -d -p 3000:3000 build2023/web:latest` ## 2. Installing Docker Compose @@ -43,18 +46,18 @@ Let's check if you can answer the following questions. **Referring to the tutorial material, run the frontend and API using Docker Compose** -Set up `docker-compose.yml` under `mercari-build-training-2022/` +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 `build2022/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 * Connecting betweeen services - * Frontend should send requests to an environment variable `API_URL` + * Frontend should send requests to an environment variable `REACT_APP_API_URL` * While API will not send requests to frontend, [CORS](https://developer.mozilla.org/ja/docs/Web/HTTP/CORS) needs to be set up such that frontend knows where the requests are coming from * Set an environment variable `FRONT_URL` for frontend URL diff --git a/document/step6.ja.md b/document/08-docker-compose.ja.md similarity index 75% rename from document/step6.ja.md rename to document/08-docker-compose.ja.md index cb54bcf85..1a6d1fb79 100644 --- a/document/step6.ja.md +++ b/document/08-docker-compose.ja.md @@ -1,20 +1,23 @@ -# STEP6: docker-composeでAPIとフロントエンドを動かす +# STEP8: docker-composeでAPIとフロントエンドを動かす このステップでは docker-compose の使い方を学びます。 **:book: Reference** -* [Docker Compose の概要](https://matsuand.github.io/docs.docker.jp.onthefly/compose/) -* [Udemy - 駆け出しエンジニアのためのDocker入門](https://www.udemy.com/course/docker-startup/) +* (JA)[Docker Compose の概要](https://matsuand.github.io/docs.docker.jp.onthefly/compose/) +* (JA)[Udemy Business - 駆け出しエンジニアのためのDocker入門](https://mercari.udemy.com/course/docker-startup/) + +* (EN)[Docker Compose Overview](https://docs.docker.com/compose/) +* (EN)[Udemy Business - Docker for the Absolute Beginner - Hands On - DevOps](https://mercari.udemy.com/course/learn-docker/) ## 1. (復習) フロントエンドの docker image を作成する **STEP4を思い出しながらフロントエンドの docker image を作成しましょう。** -`typescript/simple-mercari-web`以下にフロントエンド用の `dockerfile` がすでに用意されています。これを変更しフロントエンドが docker 上で立ち上がるようにしましょう。 +`typescript/simple-mercari-web`以下にフロントエンド用の `Dockerfile` がすでに用意されています。これを変更しフロントエンドが docker 上で立ち上がるようにしましょう。 -* 名前(リポジトリ名)は `build2022/web`, タグは`latest` とします。 +* 名前(リポジトリ名)は `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/)が正しく開ければ成功です。 @@ -41,18 +44,18 @@ ## 4. Docker ComposeでAPIとフロントエンドを動かす **チュートリアルを参考にしながら、今回作成したサービスのフロントエンドとバックエンドのAPIをDocker Composeで動かせるようにしましょう** -`docker-compose.yml` は `mercari-build-training-2022/` 以下に作成することにします。 +`docker-compose.yml` は `mercari-build-training-2023/` 以下に作成することにします。 以下の点を参考にしながら `docker-compose.yml` を作成しましょう。 * 使用する docker image - * (Option 1: 難易度 ☆) STEP4 と STEP6-1 でそれぞれ build した `build2022/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 * サービス間の接続 - * フロントエンドは`API_URL`という環境変数で設定されたURLのAPIにリクエストを送ります + * フロントエンドは`REACT_APP_API_URL`という環境変数で設定されたURLのAPIにリクエストを送ります * APIはフロントエンドにリクエストは送りませんが[CORS](https://developer.mozilla.org/ja/docs/Web/HTTP/CORS)という仕組みのために、どこからリクエストが来るのか知っておく必要があります `FRONT_URL`という環境変数でフロントエンドのURLを指定しています diff --git a/document/team-hackathon.en.md b/document/10-team-hackathon.en.md similarity index 89% rename from document/team-hackathon.en.md rename to document/10-team-hackathon.en.md index e11a92b66..6e9ff77b0 100644 --- a/document/team-hackathon.en.md +++ b/document/10-team-hackathon.en.md @@ -2,20 +2,20 @@ Form a team and propose and develop a new listing feature at Mercari. -For example, +For example, * A better and more user-friendly UI * Allow videos for listing * Use OCR for automatically input the item title * Speech-to-text input -Any types of improvement on the listing feature are welcome in different aspects like UI, Backend or AI. +Any types of improvement on the listing feature are welcome in different aspects like UI, Backend or AI. ## Development Process * Choose one person to create a repository on GitHub - * Make the repository public and add everyone in your Hackathon team as contributors + * Make the repository public and add everyone in your Hackathon team as contributors * Each team member should contribute via Pull Requests and work from their own branch **:beginner: Point** diff --git a/document/team-hackathon.ja.md b/document/10-team-hackathon.ja.md similarity index 100% rename from document/team-hackathon.ja.md rename to document/10-team-hackathon.ja.md diff --git a/go/dockerfile b/go/dockerfile index 6cd4595dc..138882f6e 100644 --- a/go/dockerfile +++ b/go/dockerfile @@ -1,4 +1,8 @@ FROM alpine -# STEP4-4では以下は変更しない +RUN addgroup -S mercari && adduser -S trainee -G mercari +# RUN chown -R trainee:mercari /path/to/db + +USER trainee + CMD ["go", "version"] diff --git a/go/go.mod b/go/go.mod index 2265223e0..7c8c43a9d 100644 --- a/go/go.mod +++ b/go/go.mod @@ -1,4 +1,4 @@ -module mercari-build-training-2022 +module mercari-build-training-2023 go 1.17 diff --git a/python/dockerfile b/python/dockerfile index 1907f2e61..08ddc2336 100644 --- a/python/dockerfile +++ b/python/dockerfile @@ -1,4 +1,8 @@ FROM alpine -# STEP4-4では以下は変更しない +RUN addgroup -S mercari && adduser -S trainee -G mercari +# RUN chown -R trainee:mercari /path/to/db + +USER trainee + CMD ["python", "-V"] diff --git a/typescript/simple-mercari-web/dockerfile b/typescript/simple-mercari-web/dockerfile index 238604b9f..2ffd5a655 100644 --- a/typescript/simple-mercari-web/dockerfile +++ b/typescript/simple-mercari-web/dockerfile @@ -1,3 +1,7 @@ FROM node:16-alpine WORKDIR /app + +RUN addgroup -S mercari && adduser -S trainee -G mercari +USER trainee + CMD ["node", "-v"] diff --git a/typescript/simple-mercari-web/public/index.html b/typescript/simple-mercari-web/public/index.html index a27a40aa6..baa091556 100644 --- a/typescript/simple-mercari-web/public/index.html +++ b/typescript/simple-mercari-web/public/index.html @@ -7,7 +7,7 @@ - Build@Mercari 2022 + Build@Mercari 2023 diff --git a/typescript/simple-mercari-web/public/manifest.json b/typescript/simple-mercari-web/public/manifest.json index 044cfb371..674d94f24 100644 --- a/typescript/simple-mercari-web/public/manifest.json +++ b/typescript/simple-mercari-web/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "Build @ Mercari 2022", - "name": "Frontend for Build@Mercari 2022", + "short_name": "Build @ Mercari 2023", + "name": "Frontend for Build@Mercari 2023", "icons": [ { "src": "favicon.ico", diff --git a/typescript/simple-mercari-web/src/components/ItemList/ItemList.tsx b/typescript/simple-mercari-web/src/components/ItemList/ItemList.tsx index bdbd31697..419728989 100644 --- a/typescript/simple-mercari-web/src/components/ItemList/ItemList.tsx +++ b/typescript/simple-mercari-web/src/components/ItemList/ItemList.tsx @@ -7,7 +7,7 @@ interface Item { image_filename: string; }; -const server = process.env.API_URL || 'http://127.0.0.1:9000'; +const server = process.env.REACT_APP_API_URL || 'http://127.0.0.1:9000'; const placeholderImage = process.env.PUBLIC_URL + '/logo192.png'; interface Prop { diff --git a/typescript/simple-mercari-web/src/components/Listing/Listing.tsx b/typescript/simple-mercari-web/src/components/Listing/Listing.tsx index b990e68b7..94e31da49 100644 --- a/typescript/simple-mercari-web/src/components/Listing/Listing.tsx +++ b/typescript/simple-mercari-web/src/components/Listing/Listing.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -const server = process.env.API_URL || 'http://127.0.0.1:9000'; +const server = process.env.REACT_APP_API_URL || 'http://127.0.0.1:9000'; interface Prop { onListingCompleted?: () => void;