set up identity project

This commit is contained in:
Simon Larsen 2022-05-08 10:33:54 +01:00
parent 4ecaccdc13
commit 47e8bfcc05
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
22 changed files with 6633 additions and 15 deletions

View File

@ -8,7 +8,7 @@ on:
- 'staging-release'
jobs:
test:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -8,7 +8,7 @@ on:
- 'staging-release'
jobs:
test:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -8,7 +8,7 @@ on:
- 'staging-release'
jobs:
test:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -8,7 +8,7 @@ on:
- 'staging-release'
jobs:
test:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -8,7 +8,7 @@ on:
- 'staging-release'
jobs:
test:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

21
.github/workflows/compile.identity.yaml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Compile Identity
on:
push:
branches-ignore:
- 'hotfix-*'
- 'release'
- 'staging-release'
jobs:
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
check-latest: true
- run: cd Common && npm install
- run: cd CommonServer && npm install
- run: cd Identity && npm install && npm run compile

View File

@ -1,4 +1,4 @@
name: haraka docker-build workflow
name: haraka Docker Build
on:
push:

View File

@ -1,4 +1,4 @@
name: Home docker-build workflow
name: Home Docker Build
on:
push:

View File

@ -0,0 +1,20 @@
name: Identity Docker Build
on:
push:
branches-ignore:
- 'hotfix-*'
- 'release'
- 'staging-release'
jobs:
# define job to build docker image
identity-docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# build image for licensing
- name: build docker image
run: npm run build-ci identity

View File

@ -1,4 +1,4 @@
name: Licensing docker-build workflow
name: Licensing Docker Build
on:
push:

View File

@ -1,4 +1,4 @@
name: Mail docker-build workflow
name: Mail Docker Build
on:
push:

View File

@ -1,4 +1,4 @@
name: Probe-api docker-build workflow
name: Probe-api Docker Build
on:
push:

12
.vscode/launch.json vendored
View File

@ -70,6 +70,18 @@
],
"type": "pwa-node"
},
{
"address": "0.0.0.0",
"localRoot": "${workspaceFolder}/Identity",
"name": "Identity: Debug with Docker",
"port": 9132,
"remoteRoot": "/usr/src/app",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"address": "0.0.0.0",
"localRoot": "${workspaceFolder}/licensing",

View File

@ -0,0 +1,61 @@
#
# OneUptime-identity Dockerfile
#
# Pull base image nodejs image.
FROM node:alpine
# Install bash.
RUN apk update && apk add bash && apk add curl
# Install python
RUN apk update && apk add --no-cache --virtual .gyp python3 make g++
#Use bash shell by default
SHELL ["/bin/bash", "-c"]
RUN npm install typescript -g
RUN mkdir /usr/src
# Install common
RUN mkdir /usr/src/Common
WORKDIR /usr/src/Common
COPY ./Common/package*.json /usr/src/Common/
RUN npm install
COPY ./Common /usr/src/Common
RUN npm run compile
# Install CommonServer
RUN mkdir /usr/src/CommonServer
WORKDIR /usr/src/CommonServer
COPY ./CommonServer/package*.json /usr/src/CommonServer/
RUN npm install
COPY ./CommonServer /usr/src/CommonServer
RUN npm run compile
#SET ENV Variables
ENV PRODUCTION=true
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# Install trivy for container scanning
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/local/bin
# Install app dependencies
COPY ./Identity/package*.json /usr/src/app/
RUN npm install
RUN npm install -g ts-node
# Bundle app source
COPY ./Identity /usr/src/app
# Expose ports.
# - 3087: OneUptime-backend
EXPOSE 3087
#Run the app
RUN npm run compile
CMD [ "npm", "start"]

View File

@ -0,0 +1,63 @@
#
# OneUptime-identity Dockerfile
#
# Pull base image nodejs image.
FROM node:alpine
# Install bash.
RUN apk update && apk add bash && apk add curl
# Install python
RUN apk update && apk add --no-cache --virtual .gyp python3 make g++
#Use bash shell by default
SHELL ["/bin/bash", "-c"]
RUN npm install typescript -g
RUN mkdir /usr/src
# Install common
RUN mkdir /usr/src/Common
WORKDIR /usr/src/Common
COPY ./Common/package*.json /usr/src/Common/
RUN npm install
COPY ./Common /usr/src/Common
RUN npm run compile
# Install CommonServer
RUN mkdir /usr/src/CommonServer
WORKDIR /usr/src/CommonServer
COPY ./CommonServer/package*.json /usr/src/CommonServer/
RUN npm install
COPY ./CommonServer /usr/src/CommonServer
RUN npm run compile
#SET ENV Variables
WORKDIR /usr/src/app
# Install trivy for container scanning
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/local/bin
# Install app dependencies
RUN cd /usr/src/app
RUN mkdir -p greenlock.d || echo "Directory already exists"
# Copy package.json files
COPY ./Identity/package.json /usr/src/app/package.json
COPY ./Identity/package-lock.json /usr/src/app/package-lock.json
RUN npm install
# Expose ports.
# - 3087: OneUptime-identity
EXPOSE 3087
EXPOSE 9229
#Run the app
RUN npm run compile
CMD [ "npm", "run", "dev"]

3
Identity/Index.ts Normal file
View File

@ -0,0 +1,3 @@
import app from 'CommonServer/Utils/StartServer';
export default app;

6358
Identity/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

26
Identity/package.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "identity",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node index.ts",
"compile": "tsc",
"dev": "cross-env NODE_ENV=development ts-node-dev --inspect=0.0.0.0 index.ts",
"audit": "npm audit --audit-level=low",
"dep-check": "depcheck ./ --skip-missing=true",
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"CommonServer": "file:../CommonServer",
"Common": "file:../Common"
},
"devDependencies": {
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"jest": "^28.1.0",
"ts-jest": "^28.0.2"
}
}

View File

@ -17,7 +17,7 @@
"dependencies": {
"axios": "^0.26.1",
"CommonServer": "file:../CommonServer",
"Common": "file:../Common",
"Common": "file:../Common",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",

View File

@ -14,6 +14,7 @@ services:
- '5400:5432'
volumes:
- postgres:/var/lib/postgresql/data
saml:
image: kenchan0130/simplesamlphp
ports:
@ -47,10 +48,27 @@ services:
- CLUSTER_KEY=test
- REALTIME_URL=http://realtime:3300
depends_on:
- redis
- haraka
- script-runner
identity:
ports:
- '3087:3087'
build:
context: .
dockerfile: ./Identity/Dockerfile
env_file:
- ./Identity/.env
environment:
- REDIS_HOST=redis
- IS_SAAS_SERVICE=${IS_SAAS_SERVICE}
- DATABASE_HOST = postgres
- CLUSTER_KEY=test
depends_on:
- redis
- postgres
accounts:
ports:
- '3003:3003'

View File

@ -227,7 +227,6 @@ services:
env_file:
- ./DashboardAPI/.env
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
- IS_SAAS_SERVICE=${IS_SAAS_SERVICE}
@ -235,7 +234,6 @@ services:
- CLUSTER_KEY=test
- REALTIME_URL=http://realtime:3300
depends_on:
- redis
volumes:
- ./dashboard-api:/usr/src/app
@ -246,6 +244,30 @@ services:
# Exclude greenlock as well.
- /usr/src/app/greenlock.d/
identity:
ports:
- '3087:3087'
- '9132:9229' # Debugging port.
build:
network: host
context: .
dockerfile: ./Identity/Dockerfile.dev
env_file:
- ./Identity/.env
environment:
- REDIS_HOST=redis
- IS_SAAS_SERVICE=${IS_SAAS_SERVICE}
- DATABASE_HOST = postgres
- CLUSTER_KEY=test
depends_on:
- redis
- postgres
volumes:
- ./Identity:/usr/src/app
# Use node modules of the container and not host system.
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
dashboard:
ports:
- '3000:3000'

View File

@ -43,10 +43,24 @@ services:
- CLUSTER_KEY=test
- REALTIME_URL=http://realtime:3300
depends_on:
- redis
- haraka
- script-runner
identity:
ports:
- '3087:3087'
image: oneuptime/identity:latest
env_file:
- ./Identity/.env
environment:
- REDIS_HOST=redis
- IS_SAAS_SERVICE=${IS_SAAS_SERVICE}
- DATABASE_HOST = postgres
- CLUSTER_KEY=test
depends_on:
- redis
- postgres
accounts:
ports:
- '3003:3003'