Skip to content

Commit 73cc76a

Browse files
authored
Docker files, linting (#8)
* upgrade libs * frontend docker * fix yml file * rm metadata from page.tsx in next-client * run prettier, eslint * pkg.json start:prod script nestjs-server start:prod * prettier cmd * docker retest on express-server * frontend dev docker fix * dockerignore * fix nestjs-server dockerfile * docker compose wip * nextjs-docker wip * nextjs docker compose running
1 parent c460417 commit 73cc76a

37 files changed

+261
-187
lines changed

.dockerignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# folders
2+
node_modules
3+
test
4+
.github
5+
.husky
6+
.next
7+
.turbo
8+
.vercel
9+
10+
# production
11+
build
12+
dist
13+
logs
14+
*.tsbuildinfo
15+
16+
# testing
17+
coverage
18+
.nyc_output
19+
20+
# misc
21+
.eslintrc
22+
.eslintrc.js
23+
.eslintignore
24+
.dockerignore
25+
.gitignore
26+
.prettierrc
27+
.prettierignore
28+
*.log
29+
*.md
30+
Dockerfile
31+
# README is not ignored, but all other .md files are ignored.
32+
!README.md

.eslintignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/github-actions.yml

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
1-
# name: github-actions
1+
name: github-actions
22

3-
# on: [push]
3+
on: [push]
44

5-
# jobs:
6-
# build:
7-
# runs-on: ubuntu-latest
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
88

9-
# strategy:
10-
# matrix:
11-
# node-version: [20.10.0]
12-
# os: [ubuntu-latest]
9+
strategy:
10+
matrix:
11+
node-version: [20.10.0]
12+
os: [ubuntu-latest]
1313

14-
# steps:
15-
# - name: Git Checkout
16-
# uses: actions/checkout@v4
14+
steps:
15+
- name: Git Checkout
16+
uses: actions/checkout@v4
1717

18-
# - name: Setup Node env
19-
# uses: actions/setup-node@v3
20-
# with:
21-
# node-version: ${{ matrix.node-version }}
22-
# cache: 'yarn'
18+
- name: Setup Node env
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'yarn'
2323

24-
# - name: Install dependencies
25-
# run: yarn
24+
- name: Install dependencies
25+
run: yarn
26+
27+
- name: Build @core/lib
28+
run: yarn lib:build
2629

27-
# - name: Build @core/lib
28-
# run: yarn lib:build
30+
- name: Build express-server
31+
run: yarn workspace express-server build
2932

30-
# - name: Build frontend
31-
# run: yarn frontend:build
33+
- name: Build nestjs-server
34+
run: yarn workspace nestjs-server build
3235

33-
# - name: Build fastify-server
34-
# run: yarn fastify-server:build
36+
- name: Build frontend
37+
run: yarn workspace frontend build
38+
39+
- name: Build next-client
40+
run: yarn workspace next-client build

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
# folders
44
node_modules
5+
logs
56
.pnp
67
.pnp.js
78
.turbo
89
.next
910
.vercel
10-
logs
1111

1212
# production
1313
build
1414
dist
1515
*.tsbuildinfo
1616

1717
# testing
18-
/coverage
19-
/.nyc_output
18+
coverage
19+
.nyc_output
2020

2121
# misc
2222
.DS_Store

.prettierignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ yarn.lock
3535
*.woff
3636

3737
# custom files
38-
*.js
39-
*.jsx
40-
*.ts
41-
*.tsx
4238
*.md
4339
*.log
4440
*.d.ts

apps/express-server/.env_sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=
2+
PORT=

apps/express-server/Dockerfile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,23 @@ FROM node:20-alpine3.18 as phase1
44
WORKDIR /app
55

66
# Run yarn only if package.json changes
7-
# copied tsconfig as shared-ui's tsconfig extends rootDir's tsconfig
8-
COPY turbo.json .
9-
COPY tsconfig.json .
10-
COPY package.json .
7+
# copied tsconfig as express-server's tsconfig extends rootDir's tsconfig
8+
COPY --chown=node:node turbo.json .
9+
COPY --chown=node:node tsconfig.json .
10+
COPY --chown=node:node package.json .
1111

1212
# first create these directories, else the copying won't work.
13-
RUN mkdir -p packages/shared
14-
RUN mkdir -p apps/server
13+
RUN mkdir -p apps/express-server
1514

1615
# copying only the required packages
17-
COPY ./packages/shared/package.json packages/shared
18-
COPY ./packages/shared packages/shared
19-
20-
COPY ./apps/server/package.json apps/server
21-
COPY ./apps/server apps/server
16+
COPY --chown=node:node ./apps/express-server/package.json apps/express-server
17+
COPY --chown=node:node ./apps/express-server apps/express-server
2218

2319
# install node_modules
2420
RUN yarn
25-
RUN yarn build:lib
2621

27-
# build server
28-
RUN yarn build-apps
22+
# build express-server
23+
RUN yarn build
2924

3025
# run server in dev env
31-
CMD ["yarn", "workspace ecom-mern-server", "build:run"]
26+
CMD ["yarn", "workspace", "express-server", "start"]

apps/express-server/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"version": "1.0.0",
55
"private": true,
66
"scripts": {
7-
"dev": "nodemon -r tsconfig-paths/register src/index.ts",
8-
"build": "rimraf dist & tsc",
9-
"build:run": "ts-node dist/index.js",
7+
"dev": "nodemon src/index.ts",
8+
"build": "rimraf dist && tsc",
9+
"start": "ts-node dist/index.js",
10+
"start:prod": "yarn build && yarn start",
1011
"lint": "eslint --fix ."
1112
},
1213
"dependencies": {
1314
"cors": "^2.8.5",
15+
"dotenv": "^16.4.4",
1416
"express": "^4.18.2",
1517
"winston": "3.11.0"
1618
},

apps/express-server/src/app-constants/env_vars.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55

66
const env = process.env;
77

8-
export const ENV_VARS = Object.freeze({ port: env.port ?? 5000 });
8+
export const ENV_VARS = Object.freeze({
9+
env: env.NODE_ENV ?? 'development',
10+
port: env.PORT ?? 5000,
11+
});

apps/express-server/src/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express, { Express, Request, Response } from 'express';
22
import cors from 'cors';
3+
import { ENV_VARS } from 'app-constants';
34
import { requestLogger } from 'middleware';
45
import * as Routes from 'routes';
56

@@ -12,7 +13,7 @@ app.use(cors());
1213
app.use(requestLogger);
1314

1415
app.get('/', (_: Request, response: Response) => {
15-
response.status(200).send('Api is up & running!!!');
16+
response.status(200).send(`ENV: ${ENV_VARS.env} - Api is up & running!!!`);
1617
});
1718

1819
app.use('/api/auth', Routes.authRouter);

0 commit comments

Comments
 (0)