Skip to content

Commit ae339d2

Browse files
committed
Merge remote-tracking branch 'origin/dev' into #159-add-typescript-support
2 parents c15495f + 319e38a commit ae339d2

27 files changed

+1814
-1277
lines changed

.github/workflows/push_image_ecr.yml

+26-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Cache Docker layers
29+
uses: actions/cache@v3
30+
with:
31+
path: /tmp/.buildx-cache
32+
key: ${{ runner.os }}-buildx-${{ github.sha }}
33+
restore-keys: |
34+
${{ runner.os }}-buildx-
35+
2536
- name: Get previous tag-version
2637
id: previous_tag
2738
uses: WyriHaximus/github-action-get-previous-tag@v1
@@ -47,15 +58,23 @@ jobs:
4758
id: login-ecr
4859
uses: aws-actions/amazon-ecr-login@v1
4960

50-
- name: Build and Push to AWS ECR
51-
id: build_image
61+
- name: Build Image and Push to AWS ECR
62+
id: build_image_and_push
63+
uses: docker/build-push-action@v5
5264
env:
5365
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
5466
IMAGE_TAG: ${{ steps.tag.outputs.tag }}
5567
ECR_REPOSITORY: taxi-back
68+
with:
69+
push: true
70+
tags: |
71+
"${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
72+
"${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest"
73+
cache-from: type=local,src=/tmp/.buildx-cache
74+
cache-to: type=local,dest=/tmp/.buildx-cache-new
75+
76+
- name: Remove old cache
5677
run: |
57-
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
58-
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
59-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
60-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
61-
echo "Push iamge : $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG and latest"
78+
rm -rf /tmp/.buildx-cache
79+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
80+

.github/workflows/push_image_ecr_dev.yml

+25-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ jobs:
2020
uses: actions/checkout@v3
2121
with:
2222
fetch-depth: 0
23-
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Cache Docker layers
28+
uses: actions/cache@v3
29+
with:
30+
path: /tmp/.buildx-cache
31+
key: ${{ runner.os }}-buildx-${{ github.sha }}
32+
restore-keys: |
33+
${{ runner.os }}-buildx-
34+
2435
- name: Configure AWS credentials
2536
uses: aws-actions/configure-aws-credentials@v1
2637
with:
@@ -31,13 +42,20 @@ jobs:
3142
- name: Login to AWS ECR
3243
id: login-ecr
3344
uses: aws-actions/amazon-ecr-login@v1
34-
35-
- name: Build and Push to AWS ECR
36-
id: build_image
45+
46+
- name: Build Image and Push to AWS ECR
47+
id: build_image_and_push
48+
uses: docker/build-push-action@v5
3749
env:
3850
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
3951
ECR_REPOSITORY: taxi-back
52+
with:
53+
push: true
54+
tags: "${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:dev"
55+
cache-from: type=local,src=/tmp/.buildx-cache
56+
cache-to: type=local,dest=/tmp/.buildx-cache-new
57+
58+
- name: Remove old cache
4059
run: |
41-
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:dev .
42-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev
43-
echo "Push iamge : $ECR_REGISTRY/$ECR_REPOSITORY:dev"
60+
rm -rf /tmp/.buildx-cache
61+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/test_ci.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,23 @@ jobs:
1212
strategy:
1313
matrix:
1414
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
15-
node-version: [16.x]
15+
node-version: ['18.x']
1616
mongodb-version: ['5.0']
1717
steps:
1818
- name: Start MongoDB
1919
run: sudo docker run --name mongodb -d -p 27017:27017 mongo:${{ matrix.mongodb-version }}
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/checkout@v3
20+
- uses: actions/checkout@v3
2221
with:
2322
submodules: true
24-
- name: Install Node.js
25-
uses: actions/setup-node@v3
26-
with:
27-
node-version: 16
28-
29-
- uses: pnpm/action-setup@v2
30-
name: Install pnpm
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v2
3125
with:
3226
version: 8
27+
- name: Install Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: 'pnpm'
3332
- id: submodule-local
3433
name: Save local version of submodule
3534
run: echo "ver=`cd sampleGenerator && git log --pretty="%h" -1 && cd ..`" >> $GITHUB_OUTPUT
@@ -53,6 +52,5 @@ jobs:
5352
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
5453
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5554
DB_PATH: ${{ secrets.DB_PATH }}
56-
FRONT_URL: ${{ secrets.FRONT_URL }}
5755
PORT: ${{ secrets.PORT }}
5856
SESSION_KEY: ${{ secrets.SESSION_KEY }}

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Force Node.js and pnpm versions according to package.json
2+
engine-strict=true

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.17.0

Dockerfile

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
FROM node:16-alpine
1+
FROM node:18-alpine
22

3-
# Copy repository
43
WORKDIR /usr/src/app
5-
COPY . .
64

7-
# Install curl (for taxi-docker)
8-
RUN apk update && apk add curl
9-
RUN npm install --global [email protected] [email protected]
5+
# Install curl(for taxi-watchtower) and pnpm
6+
RUN apk update && apk add curl && npm install --global [email protected]
107

11-
# Install requirements
12-
RUN pnpm i --force --frozen-lockfile
8+
# pnpm fetch does require only lockfile
9+
COPY pnpm-lock.yaml .
10+
11+
# Note: devDependencies are not fetched
12+
RUN pnpm fetch --prod
13+
14+
# Copy repository and install dependencies
15+
ADD . ./
16+
RUN pnpm install --offline --prod
1317

1418
# Run container
1519
EXPOSE 80
1620
ENV PORT 80
1721
CMD ["pnpm", "run", "serve"]
18-

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Taxi는 KAIST 구성원들의 택시 동승 인원 모집을 위한 서비스입
99
- Notion : [Sparcs Notion Taxi page](https://www.notion.so/sparcs/Taxi-9d371e8ac5ac4f0c9b9c35869682a0eb) (Only SPARCS members can access it)
1010
- Slack : #taxi-main, #taxi-notice, #taxi-bug-report, #taxi-github-bot, #taxi-notion-bot (Only SPARCS members can access it)
1111

12-
## Prerequisites
13-
- Recommended npm version : 8.5.5 (with node v.16.15.0)
14-
- Recommended mognoDB version : 5.0.8
15-
- [Issue with node version](https://github.com/sparcs-kaist/taxi-front/issues/76)
12+
## Prerequisite
13+
14+
- Recommended node version : >=18.0.0 (Node v18.18.0, for example)
15+
- Recommended pnpm version : >=8.0.0 (pmpm v8.8.0, for example)
16+
- Recommended mongoDB version : 5.0.8
1617

1718
## Project Setup
1819

@@ -24,15 +25,17 @@ $ git clone https://github.com/sparcs-kaist/taxi-back
2425

2526
### Install Requirements
2627
```bash
27-
$ npm install --save
28+
$ pnpm install
2829
```
2930

3031
### Set Environment Configuration
3132
See [notion page](https://www.notion.so/sparcs/Environment-Variables-1b404bd385fa495bac6d5517b57d72bf).
3233
Refer to [.env.example](.env.example) and write your own `.env`.
3334

3435
## Backend Route Information
35-
See [Backend Route Documentation](src/routes/docs/README.md)
36+
API specification is defined on Swagger.
37+
Start development server and visit `/docs` to see the specification of each endpoint.
38+
Some endpoints are not documented in Swagger yet. For those endpoints, refer to [routes/docs/README.md](./src/routes/docs/README.md).
3639

3740
## License
3841
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

loadenv.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module.exports = {
2525
secretKey: process.env.JWT_SECRET_KEY || "TAXI_JWT_KEY",
2626
option: {
2727
algorithm: "HS256",
28+
// FIXME: remove FRONT_URL from issuer. 단, issuer를 변경하면 이전에 발급했던 모든 JWT가 무효화됩니다.
29+
// See https://github.com/sparcs-kaist/taxi-back/issues/415
2830
issuer: process.env.FRONT_URL || "http://localhost:3000", // optional (default = "http://localhost:3000")
2931
},
3032
TOKEN_EXPIRED: -3,
@@ -38,10 +40,5 @@ module.exports = {
3840
slackWebhookUrl: {
3941
report: process.env.SLACK_REPORT_WEBHOOK_URL || "", // optional
4042
},
41-
eventConfig: (process.env.EVENT_CONFIG &&
42-
JSON.parse(process.env.EVENT_CONFIG)) || {
43-
mode: "2023fall",
44-
startAt: "2023-09-25T00:00:00+09:00",
45-
endAt: "2023-10-10T00:00:00+09:00",
46-
},
43+
eventConfig: (process.env.EVENT_CONFIG && JSON.parse(process.env.EVENT_CONFIG))
4744
};

package.json

+21-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
"name": "taxi-back",
33
"version": "1.0.0",
44
"description": "KAIST Taxi Party Matching Web Service",
5+
"author": "sparcs/taxi",
6+
"license": "MIT",
57
"main": "app.js",
8+
"scripts": {
9+
"preinstall": "npx only-allow pnpm",
10+
"start": "cross-env TZ='Asia/Seoul' npx nodemon app.js",
11+
"test": "npm run sample && cross-env TZ='Asia/Seoul' npm run mocha",
12+
"mocha": "cross-env TZ='Asia/Seoul' NODE_ENV=test mocha --recursive --reporter spec --exit",
13+
"serve": "cross-env TZ='Asia/Seoul' NODE_ENV=production node app.js",
14+
"lint": "npx eslint --fix .",
15+
"sample": "cd sampleGenerator && npm start && cd .."
16+
},
17+
"engines": {
18+
"node": ">=18.0.0",
19+
"pnpm": ">=8.0.0"
20+
},
621
"dependencies": {
722
"@adminjs/express": "^5.1.0",
823
"@adminjs/mongoose": "^3.0.3",
@@ -26,8 +41,8 @@
2641
"express-session": "^1.17.3",
2742
"express-validator": "^6.14.0",
2843
"firebase-admin": "^11.4.1",
29-
"jsonwebtoken": "^8.5.1",
30-
"mongoose": "^6.11.3",
44+
"jsonwebtoken": "^9.0.2",
45+
"mongoose": "^6.12.0",
3146
"node-cron": "3.0.2",
3247
"node-mocks-http": "^1.12.1",
3348
"querystring": "^0.2.1",
@@ -40,22 +55,11 @@
4055
"winston-daily-rotate-file": "^4.7.1"
4156
},
4257
"devDependencies": {
43-
"chai": "*",
58+
"chai": "^4.3.10",
4459
"eslint": "^8.22.0",
4560
"eslint-plugin-mocha": "^10.1.0",
46-
"mocha": "*",
47-
"nodemon": "^2.0.14",
61+
"mocha": "^10.2.0",
62+
"nodemon": "^3.0.1",
4863
"supertest": "^6.2.4"
49-
},
50-
"scripts": {
51-
"preinstall": "npx only-allow pnpm",
52-
"start": "cross-env TZ='Asia/Seoul' npx nodemon app.js",
53-
"test": "npm run sample && cross-env TZ='Asia/Seoul' npm run mocha",
54-
"mocha": "cross-env TZ='Asia/Seoul' NODE_ENV=test mocha --recursive --reporter spec --exit",
55-
"serve": "cross-env TZ='Asia/Seoul' NODE_ENV=production node app.js",
56-
"lint": "npx eslint --fix .",
57-
"sample": "cd sampleGenerator && npm start && cd .."
58-
},
59-
"author": "sparcs/taxi",
60-
"license": "MIT"
64+
}
6165
}

0 commit comments

Comments
 (0)