134 Commits

Author SHA1 Message Date
a2fd91fe34 Ha! Got it! And version bump
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-16 22:24:22 -04:00
967ef4e440 Updates
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-13 10:44:21 -04:00
d9285e4bec Working setups for dev and staging! (mostly)
All checks were successful
continuous-integration/drone/push Build is passing
TODO: Still no access to routes on staging... hmmm...
2023-05-12 15:37:32 -04:00
17949255d3 Maybe with a shell script...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 15:30:38 -04:00
c6e5eaf3a1 Def not
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 12:51:22 -04:00
0e220c0cf0 Remove console logging...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 08:37:52 -04:00
ebfe4339dc a lil logging
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 08:23:17 -04:00
0d3ca5382b db init script running, but no user... hmmmm 2023-05-12 08:20:41 -04:00
4477af601a Remove git attempts
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 08:13:05 -04:00
3b27300249 force yes
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 07:58:23 -04:00
47c4f4816c apt?
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-12 07:53:35 -04:00
95fdd8cf45 nope
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 22:57:06 -04:00
f7f6dcae12 Goodbye warnings?
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-11 22:50:41 -04:00
62a917677d Perhaps, more correct...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 22:17:17 -04:00
717e651cf9 Let's try this...
Some checks failed
continuous-integration/drone/push Build was killed
2023-05-11 22:08:27 -04:00
25688e1f03 Nope
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 22:00:49 -04:00
050a4f2b39 Or this?
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 21:27:56 -04:00
36093f0fb5 Or this?
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 21:25:20 -04:00
b9d5683d22 Arg...s.
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 21:20:24 -04:00
0b95587f53 Again...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 20:20:06 -04:00
486ef52745 wrong version
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 20:13:30 -04:00
ca6a6a9ab3 Bringing back the mongo build stage...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 20:02:53 -04:00
676124f23e Tried this before..
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-11 19:35:32 -04:00
d25755775e Likely not
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-11 19:02:27 -04:00
71904a53d9 Undo
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 18:36:22 -04:00
3dd7ccdcdc Giving up on a non-root user for now...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 13:00:34 -04:00
c8e08ef567 Add db and user...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 12:42:03 -04:00
cfad224c8d Revert "More paths"
All checks were successful
continuous-integration/drone/push Build is passing
This reverts commit 43dcdf4e6a.
2023-05-11 07:56:32 -04:00
43dcdf4e6a More paths
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 21:46:12 -04:00
9e3f7e2714 More path fixes
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 20:07:25 -04:00
4982175342 Fix paths
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 20:06:26 -04:00
65ff23e406 Shouldn't matter... directory structure
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 20:04:27 -04:00
a07e4ad9cc Muahahahaha
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 19:38:21 -04:00
4d813c6c2c And this
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 19:29:34 -04:00
9b0b9baf16 Give this a try (but it likely will have no effect) 2023-05-10 19:27:38 -04:00
9edbcc0bc2 Use the suboptimal...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 14:32:31 -04:00
12bff5848a Bring back the separate build step
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 14:21:52 -04:00
1bb5151fce Was the mongo version really the problem all along?
Some checks failed
continuous-integration/drone/push Build was killed
2023-05-10 14:20:55 -04:00
75c6af122f Reollback
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 14:01:38 -04:00
da36606af3 Again...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 13:50:13 -04:00
c3a689a007 DUH.
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 13:29:38 -04:00
b0ed748712 ??
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 13:28:04 -04:00
08a5b44660 hmmm 2023-05-10 13:19:49 -04:00
c80856f3c5 Adding the build back...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 13:16:03 -04:00
70737658c7 Hmmm..,.
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 13:14:09 -04:00
ebf0c6d970 Some crazy shit right here... mongo in the Dockerfile
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 13:09:30 -04:00
c92cefa903 This should work, but is suboptimal
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 12:40:16 -04:00
63e4270c89 La la la
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 12:33:16 -04:00
721edb71a1 - Build the db?
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 12:18:48 -04:00
8f20452e1a Sigh...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 11:47:08 -04:00
de58630958 Ha.
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-10 11:42:39 -04:00
f61b2b4535 Temp folder?
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-10 11:41:13 -04:00
6863d64112 Changes..
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 11:30:15 -04:00
aa52473f90 Ugh
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 11:15:43 -04:00
465e47fc10 Symlinks?
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 11:03:57 -04:00
3a721987dd This absolutely won't work...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 10:47:29 -04:00
2792753d3d Change volume inclusion back
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 10:34:47 -04:00
af6184d581 More tweaks
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 10:13:23 -04:00
40a3cdabc9 trying again... same ol mongo-init
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 10:04:09 -04:00
08e6af2eae - Trying to fix the mongo init
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-10 10:01:17 -04:00
09332aca24 fixed clone issue
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-10 09:54:33 -04:00
b161f926a9 Merge pull request 'Resolve branch name issue in pipeline trigger' (#8) from bugfix/pipeline-boken into develop
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #8
2023-05-10 13:50:40 +00:00
c406d6226c Resolve branch name issue in pipeline trigger
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-10 09:45:01 -04:00
74fd2bf32c Merge pull request 'Working Local Dev' (#7) from feature/working-local-dev into develop
Reviewed-on: #7
2023-05-10 13:40:42 +00:00
377300d288 Merge branch 'feature/working-local-dev' of ssh://git.mifi.dev:12022/mifi/auth into feature/working-local-dev
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-10 09:36:56 -04:00
83cc9be24c Drone pipeline fixes 2023-05-10 09:36:33 -04:00
4eaf354912 Merge branch 'develop' into feature/working-local-dev 2023-05-10 13:35:17 +00:00
c9a8e0746a Last second changes 2023-05-10 09:33:45 -04:00
07cca921bf Lots of updates! Working in local dev... not sure about staging yet... 2023-05-10 09:15:49 -04:00
cd980f2af9 Merge pull request 'feature/deploy-from-image-2' (#4) from feature/deploy-from-image-2 into main
Reviewed-on: #4
2023-05-10 00:48:40 +00:00
0e02c8ab15 add develop branch pr's to test checks
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone Build is failing
2023-05-09 20:39:35 -04:00
01cb2818ff Perhaps this will work! 2023-05-09 20:38:01 -04:00
67c84a7254 Merge pull request 'Switch to docker image for deploy' (#3) from feature/deploy-from-image into main
Reviewed-on: #3
2023-05-10 00:32:10 +00:00
5b15fcd60f Merge branch 'main' into feature/deploy-from-image
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone Build was killed
2023-05-10 00:27:59 +00:00
1e1eac9dd6 Switch to docker image for deploy
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-09 20:27:28 -04:00
0d2ffe0f54 Merge pull request 'Probably not...' (#2) from feature/updated_compose into main
Reviewed-on: #2
2023-05-10 00:07:49 +00:00
991dc32ce4 Some extra changes
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-09 20:04:11 -04:00
d6a72ace83 Probably not...
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-09 19:43:58 -04:00
7a0d5dc48c Merge branch 'release/0.0.37'
# Conflicts:
#	package.json
2023-05-09 19:36:14 -04:00
4ed4b6e5f4 update version
Some checks failed
continuous-integration/drone/pr Build is failing
2023-05-09 19:33:02 -04:00
4499e20e77 - Check that update route is authenticated 2023-05-09 19:28:27 -04:00
fbc1e55e5c Merge branch 'main' of ssh://git.mifi.dev:12022/mifi/auth 2023-05-09 19:15:25 -04:00
653fc7d52f promnotions 2023-05-09 19:15:01 -04:00
84881edb61 promnotions 2023-05-09 19:14:04 -04:00
c8b1b72694 New pipeline eventing 2023-05-09 19:08:17 -04:00
73cd1d794a Finalized drone pipeline (mostly)
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:52:31 -04:00
28ac23d8f2 Or one more...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:30:26 -04:00
71b7519a53 Last try then go with what works
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:28:53 -04:00
28ee1a9d1e One works... but the other...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:27:49 -04:00
f327c6e06e revert
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:18:14 -04:00
799ff00f9c Update pipeline. Again. Day 900 and something.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-09 09:17:36 -04:00
369e3f4b5c !! 2023-05-08 19:26:53 -04:00
3788de2609 ??
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 19:24:42 -04:00
0f9aafe418 ........
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 19:15:07 -04:00
13b90e9ee6 .....
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 19:13:44 -04:00
6e19a6217d Go!
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-08 19:08:55 -04:00
34fd4e7304 ...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 19:05:41 -04:00
5e04012aa4 Zoom!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:59:13 -04:00
e8f2928543 Go!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:53:26 -04:00
91a3b2fabf Do just one thing...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:40:38 -04:00
964b9a03ef New pipeline...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:31:24 -04:00
bf693645d4 Lordy...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:22:37 -04:00
082b4826c2 image_pull_secrets
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:59:12 -04:00
e68c3002d8 And again...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:37:43 -04:00
30d2f4a644 Go!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:32:52 -04:00
875a45f2b8 Perchance to dream...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:18:00 -04:00
6bf7afbe09 Fix for deploy...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:01:07 -04:00
5c94dbbff5 Maybe? Maybe not... 2023-05-08 15:59:56 -04:00
cb44eb1fab Hmmm. More trouble with secrets
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:53:27 -04:00
df63d7947f better secret file
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:47:20 -04:00
01a5ff907c Perhaps a big duh.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:37:18 -04:00
e22e3d8bc3 Muahahahaha 2023-05-08 15:33:48 -04:00
efecd78355 Publishing FTW
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:15:50 -04:00
ed4246ba0e testing secrets...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:08:49 -04:00
4acc228fe3 This one seems to be valid
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 14:57:15 -04:00
42279b0592 This. 2023-05-08 14:52:26 -04:00
e417ab64d8 Ah ha! Finally.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 14:22:19 -04:00
93b11c3a35 Fallback to old working
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 14:07:40 -04:00
1ef2c4919e Maybe these odd changes?
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:57:46 -04:00
6ff8f74317 Or this?
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:55:59 -04:00
bf70ca98f3 Or this...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:54:41 -04:00
52e5befd93 Doubtful...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:53:29 -04:00
a047b49073 Last try, then pack 2023-05-06 10:18:39 -04:00
59b20578bb Maybe
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:15:03 -04:00
cdd6c6a72a Dammit
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:12:30 -04:00
1d16473d2d Ah ha!
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:10:02 -04:00
cd2bef9811 So broken...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:00:17 -04:00
62118b6d64 ERGGGGG
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:57:46 -04:00
8290b332fb Ugh
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:56:00 -04:00
61236719f4 Or this...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:55:09 -04:00
aa699d5009 Testing this... 2023-05-06 09:48:31 -04:00
9a4f9cdf4c Hmmm 2023-05-06 09:48:00 -04:00
5532fc51a9 Unbroken? 2023-05-06 09:45:05 -04:00
99db648a36 - Endlessly fighting the ENV - I should be loading from the package... 2023-05-06 09:40:25 -04:00
14 changed files with 242 additions and 121 deletions

View File

@@ -3,7 +3,7 @@ type: docker
name: Test Pipeline name: Test Pipeline
workspace: workspace:
path: /drone/grow path: /drone/auth
steps: steps:
- name: yarn install - name: yarn install
@@ -60,18 +60,17 @@ steps:
trigger: trigger:
branch: branch:
- main - main
- develop
event: event:
# - pull_request - pull_request
- push
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: Publish Pipeline name: Publish Pipeline
group: publish
workspace: workspace:
path: /drone/grow path: /drone/auth
steps: steps:
- name: Build Package - name: Build Package
@@ -80,19 +79,13 @@ steps:
- yarn install - yarn install
- yarn build - yarn build
- name: Publish NPM - name: Publish NPM
image: plugins/npm image: node:20-alpine
failure: ignore failure: ignore
settings: commands:
username: - yarn publish -t ${DRONE_TAG}
from_secret: registry_username
password:
from_secret: registry_password
registry: https://git.mifi.dev/api/packages/mifi/npm
token:
- from_secret: gitea_token
volumes: volumes:
- name: npmrc - name: npmrc
path: /drone/grow/.npmrc path: /drone/auth/.npmrc
- name: Report NPM Publish Status - name: Report NPM Publish Status
image: plugins/webhook image: plugins/webhook
settings: settings:
@@ -109,40 +102,18 @@ steps:
- success - success
- failure - failure
- name: Publish Image - name: Publish Image
image: docker image: plugins/docker
environment: settings:
USERNAME: auto_tag: true
from_secret: registry_username repo: git.mifi.dev/mifi/mifi/auth
PASSWORD: registry: git.mifi.dev
from_secret: registry_password debug: true
commands: ssh-agent-key:
- docker login -u ${USERNAME} -p {PASSWORD} git.mifi.dev from_secret: reg_token
- docker build -t git.mifi.dev/mifi/mifi/auth:latest -t git.mifi.dev/mifi/mifi/auth:${DRONE_TAG} . username: <token>
- docker push git.mifi.dev/mifi/mifi/auth:latest password:
volumes: from_secret: reg_token
- name: dockersock secrets: [reg_token]
path: /var/run/docker.sock
- name: dockerconfig
path: /drone/grow/.docker/config.json
# - name: Publish Image
# image: plugins/docker
# settings:
# auto_tag: true
# squash: true
# repo: git.mifi.dev/mifi/auth
# context: mifi
# registry: git.mifi.dev
# username:
# from_secret: registry_username
# password:
# from_secret: registry_password
# ssh-agent-key:
# from_secret: gitea_token
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: dockerconfig
path: /drone/grow/.docker/config.json
- name: Report Image Publish Status - name: Report Image Publish Status
image: plugins/webhook image: plugins/webhook
settings: settings:
@@ -174,36 +145,36 @@ depends_on:
- Test Pipeline - Test Pipeline
trigger: trigger:
# branch:
# - main
event: event:
# - push
- tag - tag
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: Deploy Pipeline name: Staging Deploy Pipeline
workspace: workspace:
path: /drone/grow path: /drone/auth
steps: steps:
- name: Deploy Container - name: Deploy Container
image: docker image: docker
privileged: true privileged: true
environment:
CONTAINER_PREFIX: staging
HOST: area51.mifi.dev
ROUTE_PREFIX: /auth
PORT: 9001
commands: commands:
- docker compose -f docker-compose.staging.yml pull - docker compose -f docker-compose.staging-build.yml build --pull --no-cache
- docker compose -f docker-compose.staging.yml build --no-cache - docker compose -f docker-compose.staging-build.yml up --remove-orphans --force-recreate --wait
- docker compose -f docker-compose.staging.yml rm --stop
- docker compose -f docker-compose.staging.yml up --wait
volumes: volumes:
- name: env-secrets - name: env-secrets
path: /drone/grow/staging.secrets.env path: /drone/auth/staging.env
- name: dockersock - name: dockersock
path: /var/run/docker.sock path: /var/run/docker.sock
- name: dockerconfig - name: dockerconfig
path: /drone/grow/.docker/config.json path: /drone/auth/.docker/config.json
- name: Send Status Notifications - name: Send Status Notifications
image: plugins/webhook image: plugins/webhook
privileged: true privileged: true
@@ -230,14 +201,82 @@ volumes:
path: /var/run/docker.sock path: /var/run/docker.sock
- name: env-secrets - name: env-secrets
host: host:
path: /volume1/docker/beethoven/labs-auth/staging.secrets.env path: /volume1/docker/beethoven/labs-auth/staging.env
depends_on: depends_on:
- Test Pipeline - Test Pipeline
trigger: trigger:
# branch: branch:
# - main - develop
event: event:
# - push - push
- tag
---
kind: pipeline
type: docker
name: Production Deploy Pipeline
workspace:
path: /drone/auth
clone:
disable: true
steps:
- name: Deploy Container
image: docker
privileged: true
environment:
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
image: plugins/webhook
privileged: true
settings:
urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r
content_type: application/json
template: |
{
"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}}",
"username":"DroneBot"
}
when:
status:
- success
- 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:
- Test Pipeline
trigger:
event:
- promote
target:
- production

View File

@@ -6,14 +6,14 @@ ROUTE_PREFIX=/auth
LOGIN_ROUTE=/login LOGIN_ROUTE=/login
RESET_ROUTE=/reset RESET_ROUTE=/reset
DB_ADMIN_USERNAME=root # DB_ADMIN_USERNAME=root
DB_ADMIN_PASSWORD=password # DB_ADMIN_PASSWORD=password
DB_USERNAME=user DB_USERNAME=user
DB_PASSWORD=password DB_PASSWORD=password
DB_NAME=auth DB_NAME=auth
MONGO_INITDB_ROOT_USERNAME=$DB_ADMIN_USERNAME MONGO_INITDB_ROOT_USERNAME=$DB_USERNAME
MONGO_INITDB_ROOT_PASSWORD=$DB_ADMIN_PASSWORD MONGO_INITDB_ROOT_PASSWORD=$DB_PASSWORD
MONGO_INITDB_DATABASE=$DB_NAME MONGO_INITDB_DATABASE=$DB_NAME
SESSION_KEY=shjhakjfhfjdshjksdhfdshfhfduyeyb73te4 SESSION_KEY=shjhakjfhfjdshjksdhfdshfhfduyeyb73te4
@@ -27,3 +27,5 @@ RESET_VALID_MINUTES=15
DEFAULT_TOKEN_DAYS=1 DEFAULT_TOKEN_DAYS=1
CONTAINER_PREFIX=dev CONTAINER_PREFIX=dev
SERVICE_NAME=auth-service
ENV=development

View File

@@ -1,6 +0,0 @@
HOST=area51.mifi.dev
PORT=9001
ROUTE_PREFIX=/auth
CONTAINER_PREFIX=mifi

View File

@@ -1,18 +1,28 @@
ARG ENV=production
ARG MONGO_VERSION=latest
ARG PORT=9001
## mongo build stage
FROM mongo:$MONGO_VERSION AS database
COPY mongo-init.sh /docker-entrypoint-initdb.d
## stage one, build the service
FROM node:20-alpine AS build FROM node:20-alpine AS build
ENV NODE_ENV development
WORKDIR /home/node/app WORKDIR /home/node/app
COPY package*.json ./ COPY package*.json ./
COPY tsconfig.json ./ COPY tsconfig.json ./
COPY lib ./lib COPY lib ./lib
RUN ls -a RUN ls -a
RUN yarn install RUN yarn install
RUN yarn build:production RUN yarn build
## this is stage two , where the app actually runs ## this is stage two , where the app actually runs
FROM node:20-alpine AS containerize FROM node:20-alpine AS containerize
ENV NODE_ENV $ENV
WORKDIR /home/node/app WORKDIR /home/node/app
COPY package*.json ./ COPY package*.json ./
RUN yarn install --frozen-lockfile --production RUN yarn install --frozen-lockfile --production
COPY --from=0 /home/node/app/dist . COPY --from=build /home/node/app/dist .
EXPOSE 9001 EXPOSE $PORT
EXPOSE 27017
CMD ["node","server/index.js"] CMD ["node","server/index.js"]

View File

@@ -1,2 +1,2 @@
# grow-api # @mifi/auth

View File

@@ -3,26 +3,31 @@ version: '3.8'
services: services:
auth-service_mongo: auth-service_mongo:
env_file: .env.dev env_file: .env.dev
container_name: ${CONTAINER_PREFIX:-dev}-auth-service_mongo container_name: ${CONTAINER_PREFIX}-auth-service_mongo
ports: ports:
- 27017:27017 - 27017:27017
networks: networks:
- labs-net - backend
volumes: volumes:
- /var/tmp/labs:/data/db - 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:latest image: mongo:latest
auth-service: auth-service:
env_file: .env.dev env_file: .env.dev
build: . build:
container_name: ${CONTAINER_PREFIX:-dev}-auth-service context: .
args:
- PORT
- ENV
container_name: ${CONTAINER_PREFIX}-auth-service
ports: ports:
- 9001:9001 - 9001:9001
environment: environment:
- DB_HOST=${CONTAINER_PREFIX:-dev}-auth-service_mongo - DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
networks: networks:
- labs-net - labs-net
- backend
restart: unless-stopped restart: unless-stopped
image: node:20-alpine image: node:20-alpine
depends_on: depends_on:
@@ -30,3 +35,7 @@ services:
networks: networks:
labs-net: labs-net:
name: labs-net name: labs-net
volumes:
auth-db:
external: true

View File

@@ -0,0 +1,58 @@
version: '3.8'
services:
auth-service_mongo:
container_name: ${CONTAINER_PREFIX}-auth-service_mongo
env_file:
- staging.env
build:
context: .
target: database
args:
MONGO_VERSION: 4.4
networks:
- auth-backend
volumes:
- 'auth-db:/data/db'
- 'auth-db:/data/configdb'
restart: unless-stopped
image: mongo:4.4
auth-service:
container_name: ${CONTAINER_PREFIX}-auth-service
env_file:
- staging.env
build:
context: .
target: containerize
args:
- PORT
- ENV
environment:
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
labels:
- 'traefik.enable=true'
- 'traefik.docker.network=docknet'
- 'traefik.http.routers.labs-auth.rule=Host(`${HOST}`) && PathPrefix(`${ROUTE_PREFIX}`)'
- 'traefik.http.routers.labs-auth.entrypoints=websecure'
- 'traefik.http.routers.labs-auth.tls=true'
- 'traefik.http.routers.labs-auth.tls.certresolver=letsencrypt'
- 'traefik.http.routers.labs-auth.service=labs-auth-service'
- 'traefik.http.services.labs-auth-service.loadbalancer.server.port=${PORT}'
networks:
- auth-backend
- docknet
restart: unless-stopped
image: node:20-alpine
depends_on:
- auth-service_mongo
networks:
auth-backend:
driver: bridge
external: false
docknet:
name: docknet
external: true
volumes:
auth-db:
external: false

View File

@@ -2,39 +2,42 @@ version: '3.8'
services: services:
auth-service_mongo: auth-service_mongo:
container_name: $${CONTAINER_PREFIX:-mifi}-auth-service_mongo container_name: ${CONTAINER_PREFIX}-auth-service_mongo
env_file: env_file:
- .env.staging - staging.env
- staging.secrets.env
networks: networks:
- docknet - docknet
volumes: volumes:
- '/volume1/docker/labs/auth/mongo:/data/db' - auth-db:/data
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
restart: unless-stopped restart: unless-stopped
image: mongo:latest image: mongo:4.4
auth-service: auth-service:
env_file: env_file:
- .env.staging - staging.env
- staging.secrets.env container_name: ${CONTAINER_PREFIX}-auth-service
build: .
container_name: $${CONTAINER_PREFIX:-mifi}-auth-service
environment: environment:
- DB_HOST=$${CONTAINER_PREFIX:-mifi}-auth-service_mongo - DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
labels: labels:
- 'traefik.enable=true' - 'traefik.enable=true'
- 'traefik.http.routers.grow.rule=Host(`$${HOST}`) && Path(`$${ROUTE_PREFIX}`)' - 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)'
- 'traefik.http.routers.grow.entrypoints=websecure' - 'traefik.http.routers.grow.entrypoints=websecure'
- 'traefik.http.routers.grow.tls=true' - 'traefik.http.routers.grow.tls=true'
- 'traefik.http.routers.grow.tls.certresolver=letsencrypt' - 'traefik.http.routers.grow.tls.certresolver=letsencrypt'
- 'traefik.http.routers.grow.service=grow-service' - 'traefik.http.routers.grow.service=grow-service'
- 'traefik.http.services.grow-service.loadbalancer.server.port=$${PORT}' - 'traefik.http.services.grow-service.loadbalancer.server.port=${PORT}'
networks: networks:
- docknet - docknet
restart: unless-stopped restart: unless-stopped
image: node:20-alpine
depends_on: depends_on:
- auth-service_mongo - auth-service_mongo
image: git.mifi.dev/mifi/mifi/auth:latest
networks: networks:
docknet: docknet:
name: docknet name: docknet
external: true external: true
volumes:
auth-db:
external: false

View File

@@ -1,5 +1,5 @@
export const DB_HOST = process.env.DB_HOST || 'not_set'; export const DB_HOST = process.env.DB_HOST;
export const DB_PORT = process.env.DB_PORT || 27017; export const DB_PORT = process.env.DB_PORT || 27017;
export const DB_USERNAME = process.env.DB_USERNAME || 'not_set'; export const DB_USERNAME = process.env.DB_USERNAME;
export const DB_PASSWORD = process.env.DB_PASSWORD || 'not_set'; export const DB_PASSWORD = process.env.DB_PASSWORD;
export const DB_NAME = process.env.DB_NAME || 'not_set'; export const DB_NAME = process.env.DB_NAME;

View File

@@ -7,6 +7,7 @@ import Auth from '../../db/model/auth';
import { sign } from '../../utils/jwt'; import { sign } from '../../utils/jwt';
import passport from '../passport'; import passport from '../passport';
import { ErrorCodes, getErrorBody } from '../../constants/errors'; import { ErrorCodes, getErrorBody } from '../../constants/errors';
import { authenticated } from '../middleware/authenication';
const routerOpts: Router.IRouterOptions = { prefix }; const routerOpts: Router.IRouterOptions = { prefix };
const router: Router = new Router(routerOpts); const router: Router = new Router(routerOpts);
@@ -43,7 +44,10 @@ router.post(process.env.RESET_ROUTE || RESET_ROUTE, async (ctx, next) => {
ctx.body = { success: false, ...getErrorBody(ErrorCodes.RESET_REQUEST_DATA) }; ctx.body = { success: false, ...getErrorBody(ErrorCodes.RESET_REQUEST_DATA) };
}); });
router.patch('/:record', (ctx: Koa.Context) => { router.patch('/:record', authenticated(), (ctx: Koa.Context) => {
if (ctx.user !== ctx.param.record) {
ctx.throw(StatusCodes.UNAUTHORIZED);
}
const data = Auth.findOneAndUpdate({ record: ctx.params.record }); const data = Auth.findOneAndUpdate({ record: ctx.params.record });
if (!data) { if (!data) {
ctx.throw(StatusCodes.NOT_FOUND); ctx.throw(StatusCodes.NOT_FOUND);

View File

@@ -5,7 +5,7 @@ import { PORT } from '../constants/env';
connection.then( connection.then(
() => { () => {
app.listen(PORT); app.listen(PORT);
console.log('LISTENING', process.env); console.debug('Server up and listening', { env: process.env });
}, },
(err) => console.error('SERVER ERROR!', { err, env: process.env }), (err) => console.error('Could not reach database', { err, env: process.env }),
); );

View File

@@ -1,12 +0,0 @@
/* eslint-disable no-undef */
db = db.getSiblingDB(process.env.DB_NAME);
db.createUser({
user: process.env.DB_USERNAME,
pwd: process.env.DB_PASSWORD,
roles: [
{
role: 'readWrite',
db: process.env.DB_NAME,
},
],
});

14
mongo-init.sh Normal file
View File

@@ -0,0 +1,14 @@
set -e
mongo <<EOF
use $MONGO_INITDB_DATABASE
db.createUser({
user: '$DB_USERNAME',
pwd: '$DB_PASSWORD',
roles: [{
role: 'readWrite',
db: '$MONGO_INITDB_DATABASE'
}]
})
EOF

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mifi/auth", "name": "@mifi/auth",
"version": "0.0.33", "version": "0.0.39",
"author": "mifi (Mike Fitzpatrick)", "author": "mifi (Mike Fitzpatrick)",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {