Skip to content

Commit 8cb0a8d

Browse files
authored
refactor: address potential issues with deploy-compose.yml (danny-avila#1220)
* chore: remove /config/loader * chore: remove config/loader steps from Dockerfile.multi * chore: remove install script
1 parent 591808d commit 8cb0a8d

File tree

11 files changed

+25
-27
lines changed

11 files changed

+25
-27
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WORKDIR /app
77
# Install call deps - Install curl for health check
88
RUN apk --no-cache add curl && \
99
# We want to inherit env from the container, not the file
10-
# This will preserve any existing env file if it's already in souce
10+
# This will preserve any existing env file if it's already in source
1111
# otherwise it will create a new one
1212
touch .env && \
1313
# Build deps in seperate

Dockerfile.multi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Build API, Client and Data Provider
22
FROM node:19-alpine AS base
33

4-
WORKDIR /app
5-
COPY config/loader.js ./config/
6-
RUN npm install dotenv
4+
# WORKDIR /app
5+
# COPY config/loader.js ./config/
6+
# RUN touch .env
7+
# RUN npm install dotenv
78

89
WORKDIR /app/api
910
COPY api/package*.json ./
1011
COPY api/ ./
12+
RUN touch .env
1113
RUN npm install
1214

1315
# React client build

api/server/routes/oauth.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const passport = require('passport');
22
const express = require('express');
33
const router = express.Router();
4-
const config = require('../../../config/loader');
54
const { setAuthTokens } = require('../services/AuthService');
65
const { loginLimiter, checkBan } = require('../middleware');
7-
const domains = config.domains;
6+
const domains = {
7+
client: process.env.DOMAIN_CLIENT,
8+
server: process.env.DOMAIN_SERVER,
9+
};
810

911
router.use(loginLimiter);
1012

api/server/services/AuthService.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ const User = require('../../models/User');
44
const Session = require('../../models/Session');
55
const Token = require('../../models/schema/tokenSchema');
66
const { registerSchema, errorsToString } = require('../../strategies/validators');
7-
const config = require('../../../config/loader');
87
const { sendEmail } = require('../utils');
9-
const domains = config.domains;
10-
const isProduction = config.isProduction;
8+
const domains = {
9+
client: process.env.DOMAIN_CLIENT,
10+
server: process.env.DOMAIN_SERVER,
11+
};
12+
13+
const isProduction = process.env.NODE_ENV === 'production';
1114

1215
/**
1316
* Logout user

api/strategies/discordStrategy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const { Strategy: DiscordStrategy } = require('passport-discord');
22
const User = require('../models/User');
3-
const config = require('../../config/loader');
4-
const domains = config.domains;
53

64
const discordLogin = async (accessToken, refreshToken, profile, cb) => {
75
try {
@@ -52,7 +50,7 @@ module.exports = () =>
5250
{
5351
clientID: process.env.DISCORD_CLIENT_ID,
5452
clientSecret: process.env.DISCORD_CLIENT_SECRET,
55-
callbackURL: `${domains.server}${process.env.DISCORD_CALLBACK_URL}`,
53+
callbackURL: `${process.env.DOMAIN_SERVER}${process.env.DISCORD_CALLBACK_URL}`,
5654
scope: ['identify', 'email'],
5755
authorizationURL: 'https://discord.com/api/oauth2/authorize?prompt=none',
5856
},

api/strategies/facebookStrategy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const FacebookStrategy = require('passport-facebook').Strategy;
22
const User = require('../models/User');
3-
const config = require('../../config/loader');
4-
const domains = config.domains;
53

64
const facebookLogin = async (accessToken, refreshToken, profile, cb) => {
75
try {
@@ -44,7 +42,7 @@ module.exports = () =>
4442
{
4543
clientID: process.env.FACEBOOK_CLIENT_ID,
4644
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
47-
callbackURL: `${domains.server}${process.env.FACEBOOK_CALLBACK_URL}`,
45+
callbackURL: `${process.env.DOMAIN_SERVER}${process.env.FACEBOOK_CALLBACK_URL}`,
4846
proxy: true,
4947
scope: ['public_profile'],
5048
profileFields: ['id', 'email', 'name'],

api/strategies/githubStrategy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const { Strategy: GitHubStrategy } = require('passport-github2');
22
const User = require('../models/User');
3-
const config = require('../../config/loader');
4-
const domains = config.domains;
53

64
const githubLogin = async (accessToken, refreshToken, profile, cb) => {
75
try {
@@ -41,7 +39,7 @@ module.exports = () =>
4139
{
4240
clientID: process.env.GITHUB_CLIENT_ID,
4341
clientSecret: process.env.GITHUB_CLIENT_SECRET,
44-
callbackURL: `${domains.server}${process.env.GITHUB_CALLBACK_URL}`,
42+
callbackURL: `${process.env.DOMAIN_SERVER}${process.env.GITHUB_CALLBACK_URL}`,
4543
proxy: false,
4644
scope: ['user:email'],
4745
},

api/strategies/googleStrategy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const { Strategy: GoogleStrategy } = require('passport-google-oauth20');
22
const User = require('../models/User');
3-
const config = require('../../config/loader');
4-
const domains = config.domains;
53

64
const googleLogin = async (accessToken, refreshToken, profile, cb) => {
75
try {
@@ -41,7 +39,7 @@ module.exports = () =>
4139
{
4240
clientID: process.env.GOOGLE_CLIENT_ID,
4341
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
44-
callbackURL: `${domains.server}${process.env.GOOGLE_CALLBACK_URL}`,
42+
callbackURL: `${process.env.DOMAIN_SERVER}${process.env.GOOGLE_CALLBACK_URL}`,
4543
proxy: true,
4644
},
4745
googleLogin,

api/strategies/openidStrategy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const { Issuer, Strategy: OpenIDStrategy } = require('openid-client');
33
const axios = require('axios');
44
const fs = require('fs');
55
const path = require('path');
6-
const config = require('../../config/loader');
7-
const domains = config.domains;
86

97
const User = require('../models/User');
108

@@ -42,7 +40,7 @@ async function setupOpenId() {
4240
const client = new issuer.Client({
4341
client_id: process.env.OPENID_CLIENT_ID,
4442
client_secret: process.env.OPENID_CLIENT_SECRET,
45-
redirect_uris: [domains.server + process.env.OPENID_CALLBACK_URL],
43+
redirect_uris: [process.env.DOMAIN_SERVER + process.env.OPENID_CALLBACK_URL],
4644
});
4745

4846
const openidLogin = new OpenIDStrategy(

config/loader.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Env {
3535
if (fs.existsSync(this.envMap.default)) {
3636
hasDefault = true;
3737
dotenv.config({
38-
path: this.resolve(this.envMap.default),
38+
// path: this.resolve(this.envMap.default),
39+
path: path.resolve(__dirname, '..', this.envMap.default),
3940
});
4041
} else {
4142
console.warn('The default .env file was not found');
@@ -49,7 +50,8 @@ class Env {
4950
// check if the file exists
5051
if (fs.existsSync(envFile)) {
5152
dotenv.config({
52-
path: this.resolve(envFile),
53+
// path: this.resolve(envFile),
54+
path: path.resolve(__dirname, '..', envFile),
5355
});
5456
} else if (!hasDefault) {
5557
console.warn('No env files found, have you completed the install process?');

0 commit comments

Comments
 (0)