refactor: address potential issues with deploy-compose.yml (#1220)

* chore: remove /config/loader

* chore: remove config/loader steps from Dockerfile.multi

* chore: remove install script
This commit is contained in:
Danny Avila 2023-11-25 16:34:51 -05:00 committed by GitHub
parent 4dab094855
commit 12209fe0dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 27 deletions

View file

@ -7,7 +7,7 @@ WORKDIR /app
# Install call deps - Install curl for health check # Install call deps - Install curl for health check
RUN apk --no-cache add curl && \ RUN apk --no-cache add curl && \
# We want to inherit env from the container, not the file # We want to inherit env from the container, not the file
# This will preserve any existing env file if it's already in souce # This will preserve any existing env file if it's already in source
# otherwise it will create a new one # otherwise it will create a new one
touch .env && \ touch .env && \
# Build deps in seperate # Build deps in seperate

View file

@ -1,13 +1,15 @@
# Build API, Client and Data Provider # Build API, Client and Data Provider
FROM node:19-alpine AS base FROM node:19-alpine AS base
WORKDIR /app # WORKDIR /app
COPY config/loader.js ./config/ # COPY config/loader.js ./config/
RUN npm install dotenv # RUN touch .env
# RUN npm install dotenv
WORKDIR /app/api WORKDIR /app/api
COPY api/package*.json ./ COPY api/package*.json ./
COPY api/ ./ COPY api/ ./
RUN touch .env
RUN npm install RUN npm install
# React client build # React client build

View file

@ -1,10 +1,12 @@
const passport = require('passport'); const passport = require('passport');
const express = require('express'); const express = require('express');
const router = express.Router(); const router = express.Router();
const config = require('../../../config/loader');
const { setAuthTokens } = require('../services/AuthService'); const { setAuthTokens } = require('../services/AuthService');
const { loginLimiter, checkBan } = require('../middleware'); const { loginLimiter, checkBan } = require('../middleware');
const domains = config.domains; const domains = {
client: process.env.DOMAIN_CLIENT,
server: process.env.DOMAIN_SERVER,
};
router.use(loginLimiter); router.use(loginLimiter);

View file

@ -4,10 +4,13 @@ const User = require('../../models/User');
const Session = require('../../models/Session'); const Session = require('../../models/Session');
const Token = require('../../models/schema/tokenSchema'); const Token = require('../../models/schema/tokenSchema');
const { registerSchema, errorsToString } = require('../../strategies/validators'); const { registerSchema, errorsToString } = require('../../strategies/validators');
const config = require('../../../config/loader');
const { sendEmail } = require('../utils'); const { sendEmail } = require('../utils');
const domains = config.domains; const domains = {
const isProduction = config.isProduction; client: process.env.DOMAIN_CLIENT,
server: process.env.DOMAIN_SERVER,
};
const isProduction = process.env.NODE_ENV === 'production';
/** /**
* Logout user * Logout user

View file

@ -1,7 +1,5 @@
const { Strategy: DiscordStrategy } = require('passport-discord'); const { Strategy: DiscordStrategy } = require('passport-discord');
const User = require('../models/User'); const User = require('../models/User');
const config = require('../../config/loader');
const domains = config.domains;
const discordLogin = async (accessToken, refreshToken, profile, cb) => { const discordLogin = async (accessToken, refreshToken, profile, cb) => {
try { try {
@ -52,7 +50,7 @@ module.exports = () =>
{ {
clientID: process.env.DISCORD_CLIENT_ID, clientID: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET, clientSecret: process.env.DISCORD_CLIENT_SECRET,
callbackURL: `${domains.server}${process.env.DISCORD_CALLBACK_URL}`, callbackURL: `${process.env.DOMAIN_SERVER}${process.env.DISCORD_CALLBACK_URL}`,
scope: ['identify', 'email'], scope: ['identify', 'email'],
authorizationURL: 'https://discord.com/api/oauth2/authorize?prompt=none', authorizationURL: 'https://discord.com/api/oauth2/authorize?prompt=none',
}, },

View file

@ -1,7 +1,5 @@
const FacebookStrategy = require('passport-facebook').Strategy; const FacebookStrategy = require('passport-facebook').Strategy;
const User = require('../models/User'); const User = require('../models/User');
const config = require('../../config/loader');
const domains = config.domains;
const facebookLogin = async (accessToken, refreshToken, profile, cb) => { const facebookLogin = async (accessToken, refreshToken, profile, cb) => {
try { try {
@ -44,7 +42,7 @@ module.exports = () =>
{ {
clientID: process.env.FACEBOOK_CLIENT_ID, clientID: process.env.FACEBOOK_CLIENT_ID,
clientSecret: process.env.FACEBOOK_CLIENT_SECRET, clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
callbackURL: `${domains.server}${process.env.FACEBOOK_CALLBACK_URL}`, callbackURL: `${process.env.DOMAIN_SERVER}${process.env.FACEBOOK_CALLBACK_URL}`,
proxy: true, proxy: true,
scope: ['public_profile'], scope: ['public_profile'],
profileFields: ['id', 'email', 'name'], profileFields: ['id', 'email', 'name'],

View file

@ -1,7 +1,5 @@
const { Strategy: GitHubStrategy } = require('passport-github2'); const { Strategy: GitHubStrategy } = require('passport-github2');
const User = require('../models/User'); const User = require('../models/User');
const config = require('../../config/loader');
const domains = config.domains;
const githubLogin = async (accessToken, refreshToken, profile, cb) => { const githubLogin = async (accessToken, refreshToken, profile, cb) => {
try { try {
@ -41,7 +39,7 @@ module.exports = () =>
{ {
clientID: process.env.GITHUB_CLIENT_ID, clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET, clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: `${domains.server}${process.env.GITHUB_CALLBACK_URL}`, callbackURL: `${process.env.DOMAIN_SERVER}${process.env.GITHUB_CALLBACK_URL}`,
proxy: false, proxy: false,
scope: ['user:email'], scope: ['user:email'],
}, },

View file

@ -1,7 +1,5 @@
const { Strategy: GoogleStrategy } = require('passport-google-oauth20'); const { Strategy: GoogleStrategy } = require('passport-google-oauth20');
const User = require('../models/User'); const User = require('../models/User');
const config = require('../../config/loader');
const domains = config.domains;
const googleLogin = async (accessToken, refreshToken, profile, cb) => { const googleLogin = async (accessToken, refreshToken, profile, cb) => {
try { try {
@ -41,7 +39,7 @@ module.exports = () =>
{ {
clientID: process.env.GOOGLE_CLIENT_ID, clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET, clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: `${domains.server}${process.env.GOOGLE_CALLBACK_URL}`, callbackURL: `${process.env.DOMAIN_SERVER}${process.env.GOOGLE_CALLBACK_URL}`,
proxy: true, proxy: true,
}, },
googleLogin, googleLogin,

View file

@ -3,8 +3,6 @@ const { Issuer, Strategy: OpenIDStrategy } = require('openid-client');
const axios = require('axios'); const axios = require('axios');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const config = require('../../config/loader');
const domains = config.domains;
const User = require('../models/User'); const User = require('../models/User');
@ -42,7 +40,7 @@ async function setupOpenId() {
const client = new issuer.Client({ const client = new issuer.Client({
client_id: process.env.OPENID_CLIENT_ID, client_id: process.env.OPENID_CLIENT_ID,
client_secret: process.env.OPENID_CLIENT_SECRET, client_secret: process.env.OPENID_CLIENT_SECRET,
redirect_uris: [domains.server + process.env.OPENID_CALLBACK_URL], redirect_uris: [process.env.DOMAIN_SERVER + process.env.OPENID_CALLBACK_URL],
}); });
const openidLogin = new OpenIDStrategy( const openidLogin = new OpenIDStrategy(

View file

@ -35,7 +35,8 @@ class Env {
if (fs.existsSync(this.envMap.default)) { if (fs.existsSync(this.envMap.default)) {
hasDefault = true; hasDefault = true;
dotenv.config({ dotenv.config({
path: this.resolve(this.envMap.default), // path: this.resolve(this.envMap.default),
path: path.resolve(__dirname, '..', this.envMap.default),
}); });
} else { } else {
console.warn('The default .env file was not found'); console.warn('The default .env file was not found');
@ -49,7 +50,8 @@ class Env {
// check if the file exists // check if the file exists
if (fs.existsSync(envFile)) { if (fs.existsSync(envFile)) {
dotenv.config({ dotenv.config({
path: this.resolve(envFile), // path: this.resolve(envFile),
path: path.resolve(__dirname, '..', envFile),
}); });
} else if (!hasDefault) { } else if (!hasDefault) {
console.warn('No env files found, have you completed the install process?'); console.warn('No env files found, have you completed the install process?');

View file

@ -8,7 +8,6 @@
"packages/*" "packages/*"
], ],
"scripts": { "scripts": {
"install": "node config/install.js",
"update": "node config/update.js", "update": "node config/update.js",
"add-balance": "node config/add-balance.js", "add-balance": "node config/add-balance.js",
"rebuild:package-lock": "node config/packages", "rebuild:package-lock": "node config/packages",