Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextとReactのバージョンのアップデート #758

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
04ad7ed
[feat]Storybookの導入
Ryotakobayash May 24, 2024
c7c979e
Merge pull request #756 from NUTFes/feat/kobayashi/755-intro-storybook
Kubosaka May 24, 2024
3005704
[feat]react, nextのアップデート
Kubosaka May 24, 2024
889c60f
[feat]lint修正
Kubosaka May 24, 2024
6992bee
[feat]prodのversionアップ
Kubosaka May 31, 2024
5a7cbc7
[feat]ローカルでprod用を起動できるようにした
Kubosaka May 31, 2024
550a641
seedデータの更新
Kubosaka May 20, 2024
eb56ec0
[feat]教師一覧ページの定数の削除
Kubosaka May 20, 2024
ef481f9
[fix]teacherの登録・編集モーダルの学科を定数→dbの値に修正
Kubosaka May 20, 2024
6f81fae
[fix]定数→dbの値に修正
Kubosaka May 20, 2024
97b4177
[delete]DEPARTMENTS定数の削除
Kubosaka May 20, 2024
661c6c3
[fix]募金の編集で委員が局の一番上になるバグ修正
Kubosaka May 20, 2024
cac62c3
formatted by workflow
Kubosaka May 20, 2024
c65b428
[fix]ログ削除
Kubosaka May 20, 2024
e532d97
[fix]seedデータ修正
Kubosaka May 27, 2024
90af7ba
[fix]seedデータの修正
Kubosaka May 27, 2024
b51e79a
[feat]課程idごとにソートして教員データを取得
Kubosaka May 27, 2024
8e05929
[feat]パスワードリセットのリクエスト画面
Kubosaka May 24, 2024
e0aaf7a
[feat]パスワードリセット画面作成
Kubosaka May 24, 2024
753b4b7
linkをコンポーネント化
Kubosaka May 24, 2024
7a22a32
formatted by workflow
Kubosaka May 24, 2024
20d6620
[fix]パスワード変更の文修正
Kubosaka May 27, 2024
0230a2d
[fix]パスワード変更の文修正
Kubosaka May 27, 2024
9bd47b6
[fix]リセットメール送信後の文言修正
Kubosaka May 27, 2024
bb6b4d3
Merge branch 'intro-storybook-main' into version-up-nextjs
Kubosaka May 31, 2024
3a9f7ae
[fext]goをビルドして実行
Kubosaka May 31, 2024
db8399e
[fix]不要なenvファイル削除
Kubosaka May 31, 2024
40479b1
[fix]viewコンテナのビルド追加
Kubosaka May 31, 2024
f6cceb2
[fix]prodDockerfileの編集
Kubosaka May 31, 2024
d2a9085
[fix]本番環境の設定
Kubosaka Jun 4, 2024
df84924
[fix]Dockerfile修正
Kubosaka Jun 4, 2024
982f34f
Merge branch 'develop' into version-up-nextjs
Kubosaka Jun 12, 2024
fc74d64
formatted by workflow
Kubosaka Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: npm
cache-dependency-path: view/next-project/package-lock.json
- name: npm install
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ down:
seed:
docker compose run --rm api go mod tidy
docker compose run --rm api go run /app/tools/seeds/teacher_seeds.go
local-prod-run:
docker compose -f docker-compose.local-prod.yml build
docker compose -f docker-compose.local-prod.yml up
prod-run:
docker compose -f docker-compose.prod.yml build
docker compose -f docker-compose.prod.yml up -d
11 changes: 7 additions & 4 deletions api/drivers/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package db
import (
"database/sql"
"fmt"
"os"

_ "github.com/go-sql-driver/mysql"
"github.com/joho/godotenv"
"os"
)

type client struct {
Expand All @@ -18,9 +19,11 @@ type Client interface {
}

func ConnectMySQL() (client, error) {
err := godotenv.Load("env/dev.env")
if err != nil {
fmt.Println(err)
if os.Getenv("ENV") == "develop" {
err := godotenv.Load("env/dev.env")
if err != nil {
fmt.Println(err)
}
}
dbUser := os.Getenv("NUTMEG_DB_USER")
dbPassword := os.Getenv("NUTMEG_DB_PASSWORD")
Expand Down
29 changes: 13 additions & 16 deletions api/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
FROM golang:latest

# Build用 コンテナ
FROM golang:latest AS builder
WORKDIR /app
COPY . /app
ENV CGO_ENABLED=0 \
GOOS=linux
RUN go mod tidy
RUN go build -o ./main ./main.go

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y locales \
&& locale-gen ja_JP.UTF-8 \
&& echo "export LANG=ja_JP.UTF-8" >> ~/.bashrc

RUN export LANG=C.UTF-8
RUN export LANGUAGE=en_US:

ENV CGO_ENABLED=0
ENV GOOS=linux
#ENV GOARCH=amd64


# 本番用 軽量 Debian
FROM gcr.io/distroless/base-debian11:nonroot AS runner
LABEL org.opencontainers.image.source="https://github.com/NUTFes/FinanSu"
COPY --from=builder --chown=nonroot /app/main .
USER nonroot
EXPOSE 1323
CMD ["./main"]
55 changes: 55 additions & 0 deletions docker-compose.local-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: "3"
services:
db:
image: mysql:8.0
container_name: "nutfes-finansu-db"
volumes:
- ./mysql/db:/docker-entrypoint-initdb.d # 初期データ
- ./my.cnf:/etc/mysql/conf.d/my.cnf
environment:
MYSQL_DATABASE: finansu_db
MYSQL_USER: finansu
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
TZ: "Asia/Tokyo"
ports:
- "3306:3306"
restart: always

view:
build:
context: ./view
dockerfile: local-prod.Dockerfile
container_name: "nutfes-finansu-view"
command: "npm run start"
ports: ["3000:3000"]
depends_on: ["api"]

api:
build:
context: ./api
dockerfile: prod.Dockerfile
container_name: "nutfes-finansu-api"
volumes: ["./api:/app"]
ports: ["1323:1323"]
env_file: ["./api/env/dev.env"]
environment:
ENV: "production"
NUTMEG_MAIL_SENDER: "[email protected]"
NUTMEG_MAIL_PASSWORD: "xmifwkbpiybisqto"
RESET_PASSWORD_URL: "http://localhost:3000/reset_password"
depends_on:
db:
condition: service_started

minio:
image: minio/minio:latest
ports:
- "9000:9000"
- "9001:9001"
volumes:
- ./tmp/minio/data:/data
command: "server /data --console-address :9001"
environment:
MINIO_ROOT_USER: user
MINIO_ROOT_PASSWORD: password
9 changes: 4 additions & 5 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ services:
command: tunnel run

view:
build: "./view"
build:
context: ./view
dockerfile: prod.Dockerfile
container_name: "nutfes-finansu-view"
volumes: ["./view:/app"]
command: "npm run start"
ports: ["3000:3000"]
environment:
NEXT_PUBLIC_APP_ENV: "production"
depends_on: ["api"]

api:
Expand All @@ -22,10 +21,10 @@ services:
dockerfile: prod.Dockerfile
container_name: "nutfes-finansu-api"
volumes: ["./api:/app"]
command: "go run main.go"
env_file: ["./finansu.env"]
ports: ["1323:1323"]
environment:
ENV: "production"
NUTMEG_MAIL_SENDER: "[email protected]"
NUTMEG_MAIL_PASSWORD: "xmifwkbpiybisqto"
RESET_PASSWORD_URL: "https://finansu.nutfes.net/reset_password"
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ services:
command: sh -c "npm install && npm run dev"
ports:
- "3000:3000"
- "6006:6006"
stdin_open: true
environment:
NEXT_PUBLIC_ENDPOINT: minio
NEXT_PUBLIC_PORT: 9000
NEXT_PUBLIC_BUCKET_NAME: finansu
NEXT_PUBLIC_MINIO_ENDPONT: http://localhost:9000
RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED: false
tty: true

api:
Expand All @@ -40,6 +42,7 @@ services:
volumes:
- ./api:/app
environment:
ENV: "develop"
NUTMEG_MAIL_SENDER: "[email protected]"
NUTMEG_MAIL_PASSWORD: "xmifwkbpiybisqto"
RESET_PASSWORD_URL: "http://localhost:3000/reset_password"
Expand Down
6 changes: 3 additions & 3 deletions prod.view.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build用 コンテナ
FROM node:16.13.0 AS builder
FROM node:20.14 AS builder
WORKDIR /app/next-project
COPY ./view/next-project /app/next-project
RUN npm install
RUN npm run build

# 本番用 軽量 nodejs16
FROM gcr.io/distroless/nodejs16-debian11:nonroot
# 本番用 軽量 nodejs 20.14
FROM node:20.14-slim
WORKDIR /app
LABEL org.opencontainers.image.source="https://github.com/NUTFes/FinanSu"
ENV NODE_ENV production
Expand Down
4 changes: 2 additions & 2 deletions view/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ベースイメージの作成
FROM node:16.13.0
FROM node:20.14
# コンテナ内で作業するディレクトリを指定
WORKDIR /app/next-project
COPY ./ /app

ENV API_URL='http://localhost:1323'
ENV NEXT_PUBLIC_APP_ENV "develop"
9 changes: 9 additions & 0 deletions view/local-prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20.14
WORKDIR /app/next-project
COPY ./next-project /app/next-project

ENV NODE_ENV production
ENV NEXT_PUBLIC_APP_ENV "develop"

RUN npm install --production
RUN npm run build
8 changes: 6 additions & 2 deletions view/next-project/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:import/errors"
"plugin:import/errors",
"plugin:storybook/recommended"
],
"plugins": ["@typescript-eslint", "unused-imports", "import"],
"parser": "@typescript-eslint/parser",
"env": { "node": true, "es6": true },
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
Expand Down
18 changes: 18 additions & 0 deletions view/next-project/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/nextjs',
options: {},
},
staticDirs: ['../public'],
};
export default config;
14 changes: 14 additions & 0 deletions view/next-project/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
5 changes: 0 additions & 5 deletions view/next-project/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ const isProd = process.env.NEXT_PUBLIC_APP_ENV === 'production';
module.exports = {
reactStrictMode: true,
env: {
// SSR_API_URI: isProd ? 'https://finansu-api.nutfes.net' : 'https://finansu-api.nutfes.net',
// CSR_API_URI: isProd ? 'https://finansu-api.nutfes.net' : 'https://finansu-api.nutfes.net',
// SSR_API_URI: isProd ? 'http://nutfes-finansu-api:1323' : 'http://nutfes-finansu-api:1323',
// CSR_API_URI: isProd ? 'http://localhost:1323' : 'http://localhost:1323',

SSR_API_URI: isProd ? 'https://finansu-api.nutfes.net' : 'http://nutfes-finansu-api:1323',
CSR_API_URI: isProd ? 'https://finansu-api.nutfes.net' : 'http://localhost:1323',
},
Expand Down
Loading