1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-08 02:42:44 +00:00

"feat: added docker containers""

This reverts commit 9e2123cfe9.
This commit is contained in:
Saad Jutt
2021-11-14 00:55:30 +05:00
parent 64656c2919
commit d5024012c4
10 changed files with 151 additions and 0 deletions

23
.dockerignore Normal file
View File

@@ -0,0 +1,23 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md

11
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"configurations": [
{
"name": "Docker Node.js Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"platform": "node"
}
]
}

35
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,35 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "node",
"dockerBuild": {
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": ["docker-build"],
"platform": "node"
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": ["docker-build"],
"dockerRun": {
"env": {
"DEBUG": "*",
"NODE_ENV": "development"
}
},
"node": {
"enableDebugging": true
}
}
]
}

10
Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --silent && mv node_modules ../
COPY . .
EXPOSE 5000
RUN chown -R node /usr/src/app
USER node
CMD ["npm", "start"]

14
docker-compose.debug.yml Normal file
View File

@@ -0,0 +1,14 @@
version: '3.4'
services:
server:
image: server
build:
context: .
dockerfile: ./Dockerfile
environment:
NODE_ENV: development
ports:
- 3000:3000
- 9229:9229
command: ["node", "--inspect=0.0.0.0:9229", "./src/server.ts"]

34
docker-compose.yml Normal file
View File

@@ -0,0 +1,34 @@
version: '3.4'
services:
server:
image: server
build:
context: .
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
DB_CONNECT: mongodb://mongodb:27017/sasjs
ports:
- 5000:5000
volumes:
- .:/usr/src/app
links:
- mongodb
mongodb:
image: mongo:latest
ports:
- 27017:27017
volumes:
- data:/data/db
mongo-seed-users:
build: ./mongo-seed/users
links:
- mongodb
mongo-seed-clients:
build: ./mongo-seed/clients
links:
- mongodb
volumes:
data:

View File

@@ -0,0 +1,4 @@
FROM mongo
COPY ./clients.json /clients.json
CMD mongoimport --host mongodb --db sasjs --collection clients --type json --file /clients.json --jsonArray

View File

@@ -0,0 +1,6 @@
[
{
"clientId": "clientID1",
"clientSecret": "clientSecret"
}
]

View File

@@ -0,0 +1,4 @@
FROM mongo
COPY ./users.json /users.json
CMD mongoimport --host mongodb --db sasjs --collection users --type json --file /users.json --jsonArray

View File

@@ -0,0 +1,10 @@
[
{
"id": 1,
"displayName": "Super Admin",
"username": "secretuser",
"password": "$2a$10$hKvcVEZdhEQZCcxt6npazO6mY4jJkrzWvfQ5stdBZi8VTTwVMCVXO",
"isAdmin": true,
"isActive": true
}
]