Skip to content

Commit

Permalink
add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Atemndobs committed Mar 18, 2023
1 parent bb62ea7 commit c6b863c
Show file tree
Hide file tree
Showing 20 changed files with 439 additions and 23,567 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PORT="3000"
NODE_ENV="development"
SONG_BASE_URL="http://mage.tech:8899"
SONG_BASE_URL_DOCKER="http://nginx"
SONG_BASE_URL_PROD="https://141.95.67.178:32100"
S3_BUCKET="curator"
S3_URL="http://192.168.178.174:9000" # minio
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:16-alpine3.15

WORKDIR /usr/src/app

COPY package*.json ./

RUN apk add g++ make py3-pip python3
RUN npm install glob rimraf --force
RUN apk add ffmpeg
RUN pip install pydub

RUN npm install mkdirp@latest
RUN npm install -g @nestjs/cli


COPY . .


RUN npm install
RUN npm run build
44 changes: 11 additions & 33 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
version: '3'
version: '3.7'

services:
api:
build:
context: .
dockerfile: Dockerfile
args:
- NODE_ENV=development
environment:
- PORT=3000
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=postgres
- DB_PW=crudjs
dev:
container_name: nestjs_api_prod
image: atemndobs/nestjs_api_prod:v2
command: ["sh", "-c", "npm run start"]
ports:
- 3000:3000
depends_on:
- postgres
links:
- postgres:postgres
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
command: npm run dev

postgres:
image: postgres:alpine
restart: always
environment:
- DB_USER=postgres
- DB_PASS=crudjs

adminer:
image: adminer
- 9229:9229
restart: always
ports:
- 8080:8080
# volumes:
# - .:/usr/src/app
networks:
default:
name: laravel_sail
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:alpine

USER node

RUN mkdir /home/node/app
WORKDIR /home/node/app
COPY . /home/node/app
RUN npm install --production

# CMD [ "npm", "start" ]
CMD ["node", "dist/server.js"]
EXPOSE 3000

# Install development packages if NODE_ENV is set to "development"
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
RUN if [ "$NODE_ENV" == "development" ]; then npm install ; fi
39 changes: 39 additions & 0 deletions docker/Dockerfile_back
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM node:16-alpine3.15 AS development

WORKDIR /usr/src/app

COPY package*.json ./

RUN apk add g++ make py3-pip python3
RUN npm install glob rimraf --force
RUN apk add ffmpeg
RUN pip install pydub

RUN npm install mkdirp@latest

RUN npm install --only=development

RUN npm install -g @nestjs/cli

COPY . .

RUN npm run build

FROM node:16-alpine3.15 as production

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install --only=production

COPY . .

COPY --from=development /usr/src/app/dist ./dist

#

CMD ["node", "dist/main"]
42 changes: 42 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.7'

services:
api:
build:
context: .
dockerfile: Dockerfile
args:
- NODE_ENV=development
environment:
- PORT=3000



ports:
- 3000:3000
# depends_on:
# - postgres
# links:
# - postgres:postgres
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
command: npm run dev

# postgres:
# image: postgres:alpine
# restart: always
# environment:
# - DB_USER=postgres
# - DB_PASS=crudjs
#
# adminer:
# image: adminer
# restart: always
# ports:
# - 5450:8080

networks:
default:
external:
name: laravel_sail
41 changes: 41 additions & 0 deletions docker/docker-compose_back.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.7'

services:
dev:
container_name: nestjs_api_dev
image: atemndobs/nestjs_api_dev:v1
# build:
# context: .
# target: development
# dockerfile: ./Dockerfile
command: npm run start:debug
ports:
- 3000:3000
- 9229:9229
volumes:
- 'nestjs-data:/usr/src/'
restart: always

# prod:
# container_name: nestjs_api_prod
# image: nestjs_api_prod
# build:
# context: .
# target: production
# dockerfile: ./Dockerfile
# command: npm run start:prod
# ports:
# - 3000:3000
# - 9229:9229
# volumes:
# - .:/usr/src/app
# - /usr/src/app/node_modules
# - 'nestjs-data:/usr/src/'
# restart: always
networks:
default:
name: laravel_sail

volumes:
nestjs-data:
driver: local
46 changes: 46 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: Service
metadata:
name: nest-app
namespace: curator
spec:
selector:
app: nest-app
ports:
- name: http
protocol: TCP
port: 3000
targetPort: 3000
nodePort: 31200
- name: debug
protocol: TCP
port: 9229
targetPort: 9229
type: LoadBalancer
# Set the fixed port for the LoadBalancer service
# loadBalancerIP: <your-external-IP>

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nest-app
namespace: curator
spec:
replicas: 1
selector:
matchLabels:
app: nest-app
template:
metadata:
labels:
app: nest-app
spec:
containers:
- name: nest-app
image: atemndobs/nestjs_api_prod:v2
command: ["sh", "-c", "npm run start"]
ports:
- containerPort: 3000
- containerPort: 9229
imagePullPolicy: Always
39 changes: 39 additions & 0 deletions kompose/dev-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.yml
kompose.version: 1.28.0 (c4137012e)
creationTimestamp: null
labels:
io.kompose.service: dev
name: dev
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: dev
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.yml
kompose.version: 1.28.0 (c4137012e)
creationTimestamp: null
labels:
io.kompose.network/laravel-sail: "true"
io.kompose.service: dev
spec:
containers:
- args:
- sh
- -c
- npm run start
image: atemndobs/nestjs_api_prod:v2
name: nestjs-api-prod
ports:
- containerPort: 3000
- containerPort: 9229
resources: {}
restartPolicy: Always
status: {}
22 changes: 22 additions & 0 deletions kompose/dev-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.yml
kompose.version: 1.28.0 (c4137012e)
labels:
io.kompose.service: dev
name: dev
spec:
type: NodePort
ports:
- name: http
port: 3000
targetPort: 3000
nodePort: 30202
- name: debug
port: 9229
targetPort: 9229
nodePort: 31840
selector:
io.kompose.service: dev
14 changes: 14 additions & 0 deletions kompose/laravel-sail-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
creationTimestamp: null
name: laravel-sail
spec:
ingress:
- from:
- podSelector:
matchLabels:
io.kompose.network/laravel-sail: "true"
podSelector:
matchLabels:
io.kompose.network/laravel-sail: "true"
Loading

0 comments on commit c6b863c

Please sign in to comment.