Skip to content

Commit

Permalink
Merge pull request #53 from restorecommerce/feature/environment-varia…
Browse files Browse the repository at this point in the history
…bles

Feature/environment variables with fixed hardcoded OIDC Key
  • Loading branch information
yosvelquintero authored Jun 23, 2024
2 parents 4342358 + fe36ba2 commit 85b559a
Show file tree
Hide file tree
Showing 20 changed files with 2,072 additions and 3,275 deletions.
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Environment variables
CONSOLE_API_URL=http://127.0.0.1:5000
CONSOLE_OIDC_KEY=VEVTVF9DTElFTlRfSUQ6VEVTVF9DTElFTlRfU0VDUkVU=
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
- name: Install Dependencies
run: npm ci --legacy-peer-deps

- name: Create .env file
run: |
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
- name: Build
run: npm run console:build:prod

Expand All @@ -36,6 +40,10 @@ jobs:
echo ::set-output name=version_tag::$(echo ${GITHUB_REF#refs/*/})
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Create .env file
run: |
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
- name: Build
uses: docker/build-push-action@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
run: |
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Create .env file
run: |
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ Thumbs.db

.angular
.nx

# Environment variables
.env
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ These commands utilize the @nx/angular plugin provided by Nx to generate the res

To generate code from GraphQL schemas, you can utilize the following command: `npm run console:graphql:generate`. This command will generate TypeScript types and Angular services for GraphQL schemas and operations located in `./packages/modules/` with extension `.gql`.

### Set Environment Variables

Create a `.env` file in the root directory of the project with the following content:

```bash
# Environment variables
CONSOLE_API_URL=http://127.0.0.1:5000
CONSOLE_OIDC_KEY=VEVTVF9DTElFTlRfSUQ6VEVTVF9DTElFTlRfU0VDUkVU=

```

### Development Server

To start the development server, run `npm run console:serve:dev`. Navigate to `http://localhost:4200/`. The app will automatically reload if you make any changes to the source files.
Expand Down
12 changes: 12 additions & 0 deletions apps/restorecommerce/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
},
"defaultConfiguration": "development"
},
"set-env": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "node set-env.js {args.configuration}",
"forwardAllArgs": false
}
],
"parallel": false
}
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
Expand Down
4 changes: 4 additions & 0 deletions apps/restorecommerce/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import { RoutesTitleStrategyService } from './routes-title-strategy.service';
VCLProgressBarModule,
],
providers: [
{
provide: 'oidcKey',
useValue: environment.oidcKey,
},
{
provide: 'apiUrl',
useValue: environment.urls.api,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { IEnvironment } from '@console-core/types';

const baseUrl = 'http://localhost:5000';

export const environment: Readonly<IEnvironment> = {
production: false,
oidcKey: 'VEVTVF9DTElFTlRfSUQ6VEVTVF9DTElFTlRfU0VDUkVU=',
storagePrefix: 'console.dev.',
urls: {
api: baseUrl,
graphql: `${baseUrl}/graphql`,
api: 'http://192.168.1.38:5000',
graphql: 'http://192.168.1.38:5000/graphql',
},
};
7 changes: 3 additions & 4 deletions apps/restorecommerce/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { IEnvironment } from '@console-core/types';

const baseUrl = 'https://api.restorecommerce.io';

export const environment: Readonly<IEnvironment> = {
production: true,
oidcKey: 'VEVTVF9DTElFTlRfSUQ6VEVTVF9DTElFTlRfU0VDUkVU=',
storagePrefix: 'console.prod.',
urls: {
api: baseUrl,
graphql: `${baseUrl}/graphql`,
api: 'http://192.168.1.38:5000',
graphql: 'http://192.168.1.38:5000/graphql',
},
};
3 changes: 2 additions & 1 deletion nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ server {
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
}
Loading

0 comments on commit 85b559a

Please sign in to comment.