Skip to content

Commit

Permalink
copy env into container
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbuechele committed Dec 1, 2023
1 parent 9edde4c commit 941b6a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Dockerfile
node_modules
.github
.git
.env*
.flaskenv*
!.env.project
!.env.vault
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM node:20-slim

WORKDIR /usr/src/app
COPY . .
COPY package.json yarn.lock ./
RUN yarn install --production
COPY . .
RUN yarn build
CMD ["yarn", "start"]
20 changes: 8 additions & 12 deletions scripts/merge-envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ const ENV_PROD_PATH = path.join(__dirname, '..', '.env.production');
const ENV_PATH = path.join(__dirname, '..', '.env');

(async () => {
const prod = await (await fs.readFile(ENV_PROD_PATH)).toString().split('\n');
const prod = await (
await fs.readFile(ENV_PROD_PATH)
)
.toString()
.split('\n')
// filter empty vars
.filter((l) => !l.endsWith('=""'));

// adding new line
prod.unshift('');
await fs.appendFile(ENV_PATH, prod.join('\n'));
const conf = await fs.readFile(ENV_PATH);
// filter comments and empty lines
await fs.writeFile(
ENV_PATH,
conf
.toString()
.split('\n')
.filter((l) => !l.endsWith('=""'))
.filter((l) => !l.startsWith('#'))
.join('\n'),
);

const conf = await fs.readFile(ENV_PATH);
process.env = {
...process.env,
...parse(conf),
Expand Down

0 comments on commit 941b6a0

Please sign in to comment.