Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 117c78e7a9 | |||
|
95ed9bf158
|
|||
|
9dc3520989
|
|||
|
62c50964fa
|
|||
|
392414354b
|
|||
|
224eeae092
|
|||
|
64c4345c28
|
|||
|
6921bea5b5
|
|||
|
ebe086e70f
|
|||
|
af943c1e84
|
|||
|
50af0b3065
|
|||
|
50e691cf05
|
|||
|
e706ef1924
|
|||
|
0ad99d3f0a
|
|||
|
bb7b15351d
|
|||
|
bc73ab271b
|
|||
|
b1b1f3e0b9
|
44
.drone.yml
44
.drone.yml
@@ -91,6 +91,7 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- yarn set version stable
|
- yarn set version stable
|
||||||
- yarn install
|
- yarn install
|
||||||
|
- yarn build:package
|
||||||
volumes:
|
volumes:
|
||||||
- name: yarnrc
|
- name: yarnrc
|
||||||
path: /drone/auth/.yarnrc.yml
|
path: /drone/auth/.yarnrc.yml
|
||||||
@@ -125,7 +126,9 @@ steps:
|
|||||||
repo: git.mifi.dev/mifi/auth-service
|
repo: git.mifi.dev/mifi/auth-service
|
||||||
registry: git.mifi.dev
|
registry: git.mifi.dev
|
||||||
build_args:
|
build_args:
|
||||||
NPM_TOKEN:
|
- MONGO_ENTRY_FILE=latest
|
||||||
|
- MONGO_VERSION=latest
|
||||||
|
- NPM_TOKEN:
|
||||||
from_secret: reg_token
|
from_secret: reg_token
|
||||||
ssh-agent-key:
|
ssh-agent-key:
|
||||||
from_secret: reg_token
|
from_secret: reg_token
|
||||||
@@ -206,7 +209,7 @@ steps:
|
|||||||
template: |
|
template: |
|
||||||
{
|
{
|
||||||
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||||
"text": "[{{ repo.name }} - Build # {{ build.number }}] Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
"text": "[{{ repo.name }} - Build # {{ build.number }}] Staging Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||||
"username":"DroneBot"
|
"username":"DroneBot"
|
||||||
}
|
}
|
||||||
when:
|
when:
|
||||||
@@ -247,25 +250,9 @@ clone:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy Container
|
- name: Deploy Container
|
||||||
image: docker
|
image: plugins/webhook
|
||||||
privileged: true
|
settings:
|
||||||
environment:
|
urls: https://portainer.mifi.dev/api/stacks/webhooks/968d2244-2548-4f0b-8c18-bbc9bc35305d
|
||||||
CONTAINER_PREFIX: staging
|
|
||||||
HOST: area51.mifi.dev
|
|
||||||
ROUTE_PREFIX: /auth
|
|
||||||
PORT: 9001
|
|
||||||
commands:
|
|
||||||
- docker compose -f docker-compose.production-build.yml pull
|
|
||||||
- docker compose -f docker-compose.production-build.yml build --no-cache
|
|
||||||
- docker compose -f docker-compose.production-build.yml rm --stop
|
|
||||||
- docker compose -f docker-compose.production-build.yml up --wait
|
|
||||||
volumes:
|
|
||||||
- name: env-secrets
|
|
||||||
path: /drone/auth/production.env
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
- name: dockerconfig
|
|
||||||
path: /drone/auth/.docker/config.json
|
|
||||||
- name: Send Status Notifications
|
- name: Send Status Notifications
|
||||||
image: plugins/webhook
|
image: plugins/webhook
|
||||||
privileged: true
|
privileged: true
|
||||||
@@ -275,7 +262,7 @@ steps:
|
|||||||
template: |
|
template: |
|
||||||
{
|
{
|
||||||
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||||
"text": "[{{ repo.name }} - Build # {{ build.number }}] Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
"text": "[{{ repo.name }} - Build # {{ build.number }}] Production Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||||
"username":"DroneBot"
|
"username":"DroneBot"
|
||||||
}
|
}
|
||||||
when:
|
when:
|
||||||
@@ -283,19 +270,8 @@ steps:
|
|||||||
- success
|
- success
|
||||||
- failure
|
- failure
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: dockerconfig
|
|
||||||
host:
|
|
||||||
path: /volume1/docker/dockerconfig.json
|
|
||||||
- name: dockersock
|
|
||||||
host:
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
- name: env-secrets
|
|
||||||
host:
|
|
||||||
path: /volume1/docker/beethoven/labs-auth/staging.env
|
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- Test Pipeline
|
- Publish Pipeline
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
|
|||||||
24
Dockerfile
24
Dockerfile
@@ -1,20 +1,20 @@
|
|||||||
ARG ENV=production
|
ARG ENV=production
|
||||||
ARG PORT=9001
|
ARG MONGO_ENTRY_FILE
|
||||||
|
ARG MONGO_VERSION=latest
|
||||||
ARG NPM_TOKEN
|
ARG NPM_TOKEN
|
||||||
|
ARG PORT=9001
|
||||||
ARG YARN_VERSION=3.5.0
|
ARG YARN_VERSION=3.5.0
|
||||||
ARG MONGO_ENTRY_FILE=${MONGO_VERSION:-latest}
|
|
||||||
ARG MONGO_VERSION=${MONGO_VERSION:-latest}
|
|
||||||
|
|
||||||
## mongo build stage
|
## mongo build stage
|
||||||
FROM mongo:$MONGO_VERSION AS database
|
FROM mongo:${MONGO_VERSION} AS database
|
||||||
ENV NODE_ENV $ENV
|
ARG MONGO_ENTRY_FILE=${MONGO_ENTRY_FILE:-latest}
|
||||||
COPY docker-entrypoint-initdb.d/mongo-init-$MONGO_ENTRY_FILE.sh ./docker-entrypoint-initdb.d/mongo-init.sh
|
COPY docker-entrypoint-initdb.d/mongo-init-${MONGO_ENTRY_FILE}.sh ./docker-entrypoint-initdb.d/mongo-init.sh
|
||||||
|
|
||||||
## stage one, build the service
|
## stage one, build the service
|
||||||
FROM node:20-bullseye-slim AS build
|
FROM node:20-bullseye-slim AS build
|
||||||
ENV YARN_VERSION $YARN_VERSION
|
ENV YARN_VERSION=${YARN_VERSION}
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV=development
|
||||||
ENV NPM_TOKEN $NPM_TOKEN
|
ENV NPM_TOKEN=${NPM_TOKEN}
|
||||||
WORKDIR /home/node/app
|
WORKDIR /home/node/app
|
||||||
COPY .npmrc /root
|
COPY .npmrc /root
|
||||||
COPY .build.yarnrc.yml /root/.yarnrc.yml
|
COPY .build.yarnrc.yml /root/.yarnrc.yml
|
||||||
@@ -24,9 +24,9 @@ RUN yarn build:production
|
|||||||
|
|
||||||
## this is stage two , where the app actually runs
|
## this is stage two , where the app actually runs
|
||||||
FROM node:20-bullseye-slim AS containerize
|
FROM node:20-bullseye-slim AS containerize
|
||||||
ENV YARN_VERSION $YARN_VERSION
|
ENV YARN_VERSION=${YARN_VERSION}
|
||||||
ENV NODE_ENV $ENV
|
ENV NODE_ENV=${ENV}
|
||||||
ENV NPM_TOKEN $NPM_TOKEN
|
ENV NPM_TOKEN=${NPM_TOKEN}
|
||||||
WORKDIR /home/node/app
|
WORKDIR /home/node/app
|
||||||
COPY .npmrc /root
|
COPY .npmrc /root
|
||||||
COPY .build.yarnrc.yml /root/.yarnrc.yml
|
COPY .build.yarnrc.yml /root/.yarnrc.yml
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
target: database
|
target: database
|
||||||
args:
|
args:
|
||||||
MONGO_VERSION: 4.4
|
- MONGO_ENTRY_FILE=4.4
|
||||||
|
- MONGO_VERSION=4.4
|
||||||
networks:
|
networks:
|
||||||
- auth-backend
|
- auth-backend
|
||||||
volumes:
|
volumes:
|
||||||
@@ -55,4 +56,4 @@ networks:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
auth-db:
|
auth-db:
|
||||||
external: false
|
external: true
|
||||||
|
|||||||
@@ -3,41 +3,57 @@ version: '3.8'
|
|||||||
services:
|
services:
|
||||||
auth-service_mongo:
|
auth-service_mongo:
|
||||||
container_name: ${CONTAINER_PREFIX}-auth-service_mongo
|
container_name: ${CONTAINER_PREFIX}-auth-service_mongo
|
||||||
env_file:
|
|
||||||
- staging.env
|
|
||||||
networks:
|
networks:
|
||||||
|
- auth-backend
|
||||||
- docknet
|
- docknet
|
||||||
volumes:
|
volumes:
|
||||||
- auth-db:/data
|
- auth-db:/data/db
|
||||||
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
- auth-db:/data/configdb
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: mongo:4.4
|
image: mongo:${MONGO_VERSION}
|
||||||
auth-service:
|
auth-service:
|
||||||
env_file:
|
|
||||||
- staging.env
|
|
||||||
container_name: ${CONTAINER_PREFIX}-auth-service
|
container_name: ${CONTAINER_PREFIX}-auth-service
|
||||||
environment:
|
environment:
|
||||||
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
|
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
|
||||||
|
- DB_NAME=${DB_NAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DEFAULT_TOKEN_DAYS=${DEFAULT_TOKEN_DAYS}
|
||||||
|
- JWT_AUDIENCE=${JWT_AUDIENCE}
|
||||||
|
- JWT_ISSUER=${JWT_ISSUER}
|
||||||
|
- JWT_SECRET=${JWT_SECRET}
|
||||||
|
- LOGIN_ROUTE=${LOGIN_ROUTE}
|
||||||
|
- LOGIN_VALID_TIME=${LOGIN_VALID_TIME}
|
||||||
|
- PORT=${PORT}
|
||||||
|
- RESET_ROUTE=${RESET_ROUTE}
|
||||||
|
- RESET_VALID_MINUTES=${RESET_VALID_MINUTES}
|
||||||
|
- ROUTE_PREFIX=${ROUTE_PREFIX}
|
||||||
|
- SESSION_KEY=${SESSION_KEY}
|
||||||
labels:
|
labels:
|
||||||
- 'traefik.enable=true'
|
- 'traefik.enable=true'
|
||||||
- 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)'
|
- 'traefik.docker.network=docknet'
|
||||||
- 'traefik.http.routers.grow.entrypoints=websecure'
|
- 'traefik.http.routers.auth.rule=Host(`${HOST}`) && PathPrefix(`${ROUTE_PREFIX}`)'
|
||||||
- 'traefik.http.routers.grow.tls=true'
|
- 'traefik.http.routers.auth.entrypoints=websecure'
|
||||||
- 'traefik.http.routers.grow.tls.certresolver=letsencrypt'
|
- 'traefik.http.routers.auth.tls=true'
|
||||||
- 'traefik.http.routers.grow.service=grow-service'
|
- 'traefik.http.routers.auth.tls.certresolver=letsencrypt'
|
||||||
- 'traefik.http.services.grow-service.loadbalancer.server.port=${PORT}'
|
- 'traefik.http.routers.auth.service=auth-service'
|
||||||
|
- 'traefik.http.services.auth-service.loadbalancer.server.port=${PORT}'
|
||||||
networks:
|
networks:
|
||||||
|
- auth-backend
|
||||||
- docknet
|
- docknet
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- auth-service_mongo
|
- auth-service_mongo
|
||||||
image: git.mifi.dev/mifi/mifi/auth:latest
|
image: git.mifi.dev/mifi/auth-service:latest
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
auth-backend:
|
||||||
|
driver: bridge
|
||||||
|
external: false
|
||||||
docknet:
|
docknet:
|
||||||
name: docknet
|
name: docknet
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
auth-db:
|
auth-db:
|
||||||
external: false
|
external: true
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@mifi/auth-service",
|
"name": "@mifi/auth-service",
|
||||||
"version": "1.0.6",
|
"version": "1.0.12",
|
||||||
"author": "mifi (Mike Fitzpatrick)",
|
"author": "mifi (Mike Fitzpatrick)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
"build:package": "tsc -p ./tsconfig.package.json",
|
||||||
"build:production": "tsc -p ./tsconfig.production.json",
|
"build:production": "tsc -p ./tsconfig.production.json",
|
||||||
"format": "prettier:fix && lint:fix",
|
"format": "prettier:fix && lint:fix",
|
||||||
"lint": "eslint --ext .ts,.tsx src/",
|
"lint": "eslint --ext .ts,.tsx src/",
|
||||||
|
|||||||
17
tsconfig.package.json
Normal file
17
tsconfig.package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": "@tsconfig/node16/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"declaration": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"outDir": "dist/",
|
||||||
|
"rootDirs": ["./", "src/"],
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"sourceMap": false,
|
||||||
|
"removeComments": true
|
||||||
|
},
|
||||||
|
"include": ["./src"]
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"extends": "@tsconfig/node16/tsconfig.json",
|
"extends": "@tsconfig/node16/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"declaration": true,
|
"declaration": false,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user