Dockerfile inital
This commit is contained in:
parent
72fb6fbc20
commit
3907482b06
4 changed files with 39 additions and 9 deletions
6
.dockerignore
Normal file
6
.dockerignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# NodeJs
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
.git/
|
||||||
|
export/
|
||||||
|
.env
|
24
Dockerfile
Normal file
24
Dockerfile
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
FROM node:18-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:18-alpine AS prod
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=build /app/dist /app/dist
|
||||||
|
COPY --from=build /app/node_modules /app/node_modules
|
||||||
|
COPY --from=build /app/package.json /app/package.json
|
||||||
|
COPY --from=build /app/.env /app/.env
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
CMD [ "npm", "run", "start" ]
|
|
@ -23,20 +23,20 @@ export const CLUB_NAME = process.env.CLUB_NAME ?? "";
|
||||||
|
|
||||||
export function configCheck() {
|
export function configCheck() {
|
||||||
if (DB_TYPE != "mysql" && DB_TYPE != "sqlite") throw new Error("set valid value to DB_TYPE (mysql|sqlite)");
|
if (DB_TYPE != "mysql" && DB_TYPE != "sqlite") throw new Error("set valid value to DB_TYPE (mysql|sqlite)");
|
||||||
if (DB_HOST == "" ?? typeof DB_HOST != "string") throw new Error("set valid value to DB_HOST");
|
if (DB_HOST == "" || typeof DB_HOST != "string") throw new Error("set valid value to DB_HOST");
|
||||||
if (DB_NAME == "" ?? typeof DB_NAME != "string") throw new Error("set valid value to DB_NAME");
|
if (DB_NAME == "" || typeof DB_NAME != "string") throw new Error("set valid value to DB_NAME");
|
||||||
if (DB_USERNAME == "" ?? typeof DB_USERNAME != "string") throw new Error("set valid value to DB_USERNAME");
|
if (DB_USERNAME == "" || typeof DB_USERNAME != "string") throw new Error("set valid value to DB_USERNAME");
|
||||||
if (DB_PASSWORD == "" ?? typeof DB_PASSWORD != "string") throw new Error("set valid value to DB_PASSWORD");
|
if (DB_PASSWORD == "" || typeof DB_PASSWORD != "string") throw new Error("set valid value to DB_PASSWORD");
|
||||||
|
|
||||||
if (typeof SERVER_PORT != "number") throw new Error("set valid numeric value to SERVER_PORT");
|
if (typeof SERVER_PORT != "number") throw new Error("set valid numeric value to SERVER_PORT");
|
||||||
|
|
||||||
if (JWT_SECRET == "" ?? typeof JWT_SECRET != "string") throw new Error("set valid value to JWT_SECRET");
|
if (JWT_SECRET == "" || typeof JWT_SECRET != "string") throw new Error("set valid value to JWT_SECRET");
|
||||||
checkMS(JWT_EXPIRATION, "JWT_EXPIRATION");
|
checkMS(JWT_EXPIRATION, "JWT_EXPIRATION");
|
||||||
checkMS(REFRESH_EXPIRATION, "REFRESH_EXPIRATION");
|
checkMS(REFRESH_EXPIRATION, "REFRESH_EXPIRATION");
|
||||||
|
|
||||||
if (MAIL_USERNAME == "" ?? typeof MAIL_USERNAME != "string") throw new Error("set valid value to MAIL_USERNAME");
|
if (MAIL_USERNAME == "" || typeof MAIL_USERNAME != "string") throw new Error("set valid value to MAIL_USERNAME");
|
||||||
if (MAIL_PASSWORD == "" ?? typeof MAIL_PASSWORD != "string") throw new Error("set valid value to MAIL_PASSWORD");
|
if (MAIL_PASSWORD == "" || typeof MAIL_PASSWORD != "string") throw new Error("set valid value to MAIL_PASSWORD");
|
||||||
if (MAIL_HOST == "" ?? typeof MAIL_HOST != "string") throw new Error("set valid value to MAIL_HOST");
|
if (MAIL_HOST == "" || typeof MAIL_HOST != "string") throw new Error("set valid value to MAIL_HOST");
|
||||||
if (typeof MAIL_PORT != "number") throw new Error("set valid numeric value to MAIL_PORT");
|
if (typeof MAIL_PORT != "number") throw new Error("set valid numeric value to MAIL_PORT");
|
||||||
if (MAIL_SECURE != "true" && MAIL_SECURE != "false") throw new Error("set 'true' or 'false' to MAIL_SECURE");
|
if (MAIL_SECURE != "true" && MAIL_SECURE != "false") throw new Error("set 'true' or 'false' to MAIL_SECURE");
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ const app = express();
|
||||||
import router from "./routes/index";
|
import router from "./routes/index";
|
||||||
import { PermissionObject } from "./type/permissionTypes";
|
import { PermissionObject } from "./type/permissionTypes";
|
||||||
router(app);
|
router(app);
|
||||||
app.listen(SERVER_PORT, () => {
|
app.listen(process.env.NODE_ENV ? SERVER_PORT : 5000, () => {
|
||||||
console.log(`listening on *:${SERVER_PORT}`);
|
console.log(`listening on *:${SERVER_PORT}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue