fix: Be sure .env exists

This commit is contained in:
Andras Bacsai 2022-02-28 09:31:36 +01:00
parent 716aa36bfd
commit c3d39e1dd4

View File

@ -239,10 +239,16 @@ export default async function (job) {
baseDirectory, baseDirectory,
publishDirectory publishDirectory
}); });
let envFound = false;
try {
envFound = !!(await fs.stat(`${workdir}/.env`));
} catch (error) {
//
}
try { try {
saveBuildLog({ line: 'Deployment started.', buildId, applicationId }); saveBuildLog({ line: 'Deployment started.', buildId, applicationId });
const { stderr } = await asyncExecShell( const { stderr } = await asyncExecShell(
`DOCKER_HOST=${host} docker run --env-file=${workdir}/.env ${labels.join( `DOCKER_HOST=${host} docker run ${envFound && `--env-file=${workdir}/.env`} ${labels.join(
' ' ' '
)} --name ${imageId} --network ${ )} --name ${imageId} --network ${
docker.network docker.network