Fixing environment variable handling
continuous-integration/drone/push Build is passing Details

main
Félix MIELCAREK 11 months ago
parent a1a13e48bc
commit 3efff073c3

@ -1,10 +1,5 @@
FROM node:latest FROM node:latest
# Install Python and pip
RUN apt-get update && \
apt-get install -y python3 python3-pip && \
rm -rf /var/lib/apt/lists/*
# Set working directory inside the container # Set working directory inside the container
WORKDIR /usr/src/app WORKDIR /usr/src/app
@ -12,12 +7,10 @@ COPY callback-server/package*.json ./callback-server/
RUN npm install ./callback-server RUN npm install ./callback-server
COPY callback-server ./callback-server/ COPY callback-server ./callback-server/
COPY common ./common/ RUN env | awk -F= '{print $1 "=" $1}' > .env
RUN touch common/.env
RUN python3 common/set-env-var.py
# Expose the port the app runs on # Expose the port the app runs on
EXPOSE 80 EXPOSE 80
# Command to run the application # Command to run the application
CMD ["node", "--env-file=common/.env" , "callback-server/app.js"] CMD ["node", "--env-file=.env" , "callback-server/app.js"]

@ -6,9 +6,12 @@ const cors = require('cors');
//#endregion //#endregion
//#region CONSTANTS //#region CONSTANTS
const port = 80
const clientId = process.env.CLIENT_ID; const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET; const clientSecret = process.env.CLIENT_SECRET;
const mariadbUser = process.env.MARIADB_USER;
const mariadbDatabase = process.env.MARIADB_DATABASE;
const mariadbPassword = process.env.MARIADB_PASSWORD;
const port = 80
const redirectUri = 'https://felixmielcarek.github.io/big-brother/callback/'; const redirectUri = 'https://felixmielcarek.github.io/big-brother/callback/';
const allowedDomain = [ 'https://felixmielcarek.github.io' ]; const allowedDomain = [ 'https://felixmielcarek.github.io' ];
//#endregion //#endregion
@ -82,9 +85,9 @@ app.post('/', async (req, res) => {
try { try {
const pool = mariadb.createPool({ const pool = mariadb.createPool({
host: 'felixmielcarek-bigbrotherdb', host: 'felixmielcarek-bigbrotherdb',
user: process.env.MARIADB_USER, user: mariadbUser,
database: process.env.MARIADB_DATABASE, database: mariadbDatabase,
password: process.env.MARIADB_PASSWORD, password: mariadbPassword,
connectionLimit: 5 connectionLimit: 5
}); });
@ -137,9 +140,9 @@ app.get('/settings/deactivate', async (req,res) => {
try { try {
const pool = mariadb.createPool({ const pool = mariadb.createPool({
host: 'felixmielcarek-bigbrotherdb', host: 'felixmielcarek-bigbrotherdb',
user: process.env.MARIADB_USER, user: mariadbUser,
database: process.env.MARIADB_DATABASE, database: mariadbDatabase,
password: process.env.MARIADB_PASSWORD, password: mariadbPassword,
connectionLimit: 5 connectionLimit: 5
}); });

@ -1,8 +0,0 @@
import os
with open('.env', 'w') as f:
f.write("MARIADB_USER={}\n".format(os.getenv('MARIADB_USER')))
f.write("MARIADB_PASSWORD={}\n".format(os.getenv('MARIADB_PASSWORD')))
f.write("MARIADB_DATABASE={}\n".format(os.getenv('MARIADB_DATABASE')))
f.write("CLIENT_ID={}\n".format(os.getenv('CLIENT_ID')))
f.write("CLIENT_SECRET={}\n".format(os.getenv('CLIENT_SECRET')))
Loading…
Cancel
Save