mirror of
https://github.com/sasjs/server.git
synced 2026-01-16 10:20:05 +00:00
chore: copy sas exe script extracted common
This commit is contained in:
@@ -4,6 +4,7 @@ COPY ["package.json","package-lock.json", "./"]
|
|||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY ./api .
|
COPY ./api .
|
||||||
COPY ./certificates ../certificates
|
COPY ./certificates ../certificates
|
||||||
|
COPY ./sas_exe ../sas_exe
|
||||||
# RUN chown -R node /usr/server/api
|
# RUN chown -R node /usr/server/api
|
||||||
# USER node
|
# USER node
|
||||||
CMD ["npm","start"]
|
CMD ["npm","start"]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import mongoose from 'mongoose'
|
|||||||
import { configuration } from '../../package.json'
|
import { configuration } from '../../package.json'
|
||||||
import { getDesktopFields } from '.'
|
import { getDesktopFields } from '.'
|
||||||
import { populateClients } from '../routes/api/auth'
|
import { populateClients } from '../routes/api/auth'
|
||||||
|
import { fileExists } from '@sasjs/utils'
|
||||||
|
|
||||||
export const connectDB = async () => {
|
export const connectDB = async () => {
|
||||||
const { MODE } = process.env
|
const { MODE } = process.env
|
||||||
@@ -18,10 +19,13 @@ export const connectDB = async () => {
|
|||||||
} else {
|
} else {
|
||||||
const { SAS_EXEC } = process.env
|
const { SAS_EXEC } = process.env
|
||||||
process.sasLoc = SAS_EXEC
|
process.sasLoc = SAS_EXEC
|
||||||
? path.join(__dirname, '..', '..', '...', SAS_EXEC)
|
? path.join(__dirname, '..', '..', '..', SAS_EXEC)
|
||||||
: configuration.sasPath
|
: configuration.sasPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('SAS_EXEC: ', process.sasLoc)
|
||||||
|
console.log('SAS_EXEC Exists: ', await fileExists(process.sasLoc))
|
||||||
|
|
||||||
// NOTE: when exporting app.js as agent for supertest
|
// NOTE: when exporting app.js as agent for supertest
|
||||||
// we should exlcude connecting to the real database
|
// we should exlcude connecting to the real database
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ services:
|
|||||||
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
||||||
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
||||||
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
||||||
|
SAS_EXEC: ${SAS_EXEC}
|
||||||
expose:
|
expose:
|
||||||
- ${PORT_API}
|
- ${PORT_API}
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
21
dockerSASexe.sh
Executable file
21
dockerSASexe.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/')
|
||||||
|
|
||||||
|
if [ -z "$sasjsPath" ]
|
||||||
|
then
|
||||||
|
echo "Please enter path to SAS executable:"
|
||||||
|
read sasjsPath
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $sasjsPath ]
|
||||||
|
then
|
||||||
|
echo "Using sas executable:" \"$sasjsPath\"
|
||||||
|
else
|
||||||
|
echo "No file present at:" \"$sasjsPath\"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# copy sas executable to current directory, because docker cannot copy files outside of context.
|
||||||
|
rm -rf sas_exe
|
||||||
|
mkdir sas_exe
|
||||||
|
cp $sasjsPath ./sas_exe/sas
|
||||||
@@ -1,29 +1,6 @@
|
|||||||
sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/')
|
|
||||||
|
|
||||||
if [ -z "$sasjsPath" ]
|
# Copy SAS executable from source to current folder to make it available to docker
|
||||||
then
|
./dockerSASexe.sh
|
||||||
echo "Please enter path to SAS executable:"
|
|
||||||
read sasjsPath
|
|
||||||
|
|
||||||
fi
|
# Run docker-compose with default docker compose file i.e. docker-compose.yml
|
||||||
|
# SAS_EXEC=sas_exe/sas docker-compose up -d
|
||||||
if [ -e $sasjsPath ]
|
|
||||||
then
|
|
||||||
echo "Using sas executable:" \"$sasjsPath\"
|
|
||||||
else
|
|
||||||
echo "No file present at:" \"$sasjsPath\"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy sas executable to current directory, because docker cannot copy files outside of context.
|
|
||||||
cp $sasjsPath ./
|
|
||||||
|
|
||||||
# name of the sas executable file, placed at root of repository
|
|
||||||
sasjs=$(basename $sasjsPath)
|
|
||||||
echo "SAS Executable name:" $sasjs
|
|
||||||
|
|
||||||
# build and run docker-compose
|
|
||||||
SAS_EXEC=$sasjs docker-compose up --build -d
|
|
||||||
|
|
||||||
# remove copied sas executable
|
|
||||||
rm $sasjs
|
|
||||||
|
|||||||
@@ -1,29 +1,6 @@
|
|||||||
sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/')
|
|
||||||
|
|
||||||
if [ -z "$sasjsPath" ]
|
# Copy SAS executable from source to current folder to make it available to docker
|
||||||
then
|
./dockerSASexe.sh
|
||||||
echo "Please enter path to SAS executable:"
|
|
||||||
read sasjsPath
|
|
||||||
|
|
||||||
fi
|
# Build & Run docker-compose with docker compose file i.e. docker-compose.prod.yml
|
||||||
|
# SAS_EXEC=sas_exe/sas docker-compose -f docker-compose.prod.yml up --build -d
|
||||||
if [ -e $sasjsPath ]
|
|
||||||
then
|
|
||||||
echo "Using sas executable:" \"$sasjsPath\"
|
|
||||||
else
|
|
||||||
echo "No file present at:" \"$sasjsPath\"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy sas executable to current directory, because docker cannot copy files outside of context.
|
|
||||||
cp $sasjsPath ./
|
|
||||||
|
|
||||||
# name of the sas executable file, placed at root of repository
|
|
||||||
sasjs=$(basename $sasjsPath)
|
|
||||||
echo "SAS Executable name:" $sasjs
|
|
||||||
|
|
||||||
# build and run docker-compose
|
|
||||||
SAS_EXEC=$sasjs docker-compose -f docker-compose.prod.yml up --build -d
|
|
||||||
|
|
||||||
# remove copied sas executable
|
|
||||||
rm $sasjs
|
|
||||||
|
|||||||
Reference in New Issue
Block a user