Skip to content

Commit

Permalink
build: add env variables for backend url
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablito2020 committed Oct 23, 2023
1 parent e26887b commit 2580254
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM node:20-alpine as build
ARG BACKEND_URL
ENV BACKEND_URL $BACKEND_URL
WORKDIR /app
COPY ./app/package*.json /app/
RUN npm install -g ionic
RUN npm install
COPY ./app /app/
ENV NODE_OPTIONS=--max_old_space_size=4096
RUN npm run config
RUN ionic build --prod
FROM nginx:alpine
COPY ./nginx.conf /etc/nginx/nginx.conf
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"config": "node set-env.js",
"lint": "ng lint",
"lint-staged": {
"*": "prettier --write"
Expand Down
19 changes: 19 additions & 0 deletions app/set-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');

const backendUrl = process.env['BACKEND_URL'];

const productionEnvironmentFile = `
export const environment = {
production: true,
API: "${backendUrl}",
};
`

fs.writeFile('./src/environments/environment.prod.ts', productionEnvironmentFile, err => {
if (err) {
console.error("Error writing environment.prod.ts file");
console.error(err);
} else {
console.log(`Generated production environment file`);
}
})
4 changes: 0 additions & 4 deletions app/src/environments/environment.prod.ts

This file was deleted.

0 comments on commit 2580254

Please sign in to comment.