Skip to content

sample-ecommerce: add dockerfile, update dependencies, add pm2 #38

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

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions sample-service/sample-ecommerce/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
**/node_modules
**/dist
10 changes: 10 additions & 0 deletions sample-service/sample-ecommerce/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:alpine

WORKDIR /usr/src/app

COPY . .
RUN yarn
EXPOSE 8080
RUN yarn build

CMD ["yarn", "start:prod"]
5 changes: 4 additions & 1 deletion sample-service/sample-ecommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@
"watch": "tsc -w",
"dev": "nodemon -r tsconfig-paths/register src/index.ts",
"start": "TS_NODE_BASEURL=./dist node -r tsconfig-paths/register dist/index.js",
"start:prod": "pm2-runtime start pm2.json -i max",
"format": "prettier --write './src/**/*.{ts,tsx}'"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"crypto": "^1.0.1",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"pm2": "^5.2.2",
"sqlite3": "^5.0.11",
"typeorm": "^0.3.9"
},
"devDependencies": {
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.2",
"@types/express": "^4.17.13",
"@types/node": "^18.6.1",
"nodemon": "^2.0.19",
Expand Down
12 changes: 12 additions & 0 deletions sample-service/sample-ecommerce/pm2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"apps": [
{
"name": "app",
"script": "dist/index.js",
"node_args": "-r ts-node/register -r tsconfig-paths/register",
"env": {
"TS_NODE_BASEURL": "./dist"
}
}
]
}
2 changes: 1 addition & 1 deletion sample-service/sample-ecommerce/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare global {
}

const app: Express = express()
const port = process.env.PORT || 8082
const port = process.env.PORT || 8080

app.disable("x-powered-by")
app.use(express.json())
Expand Down
2 changes: 1 addition & 1 deletion sample-service/sample-ecommerce/src/services/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomBytes } from "crypto"
import bcrypt from "bcrypt"
import bcrypt from "bcryptjs"
import { AppDataSource } from "data-source"
import { Error400BadRequest, Error404NotFound, Error409Conflict } from "errors"
import { User } from "models"
Expand Down
2 changes: 1 addition & 1 deletion sample-service/sample-ecommerce/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import bcrypt from "bcrypt"
import bcrypt from "bcryptjs"
import { StringHashError } from "errors"

const SALT_ROUNDS = 10
Expand Down
Loading