Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cd6a676
Innecesary env files deleted
Jul 6, 2022
9dd2d22
New changes to env files
Jul 6, 2022
5cd8097
Merge from master
Jul 6, 2022
cee7a67
Add 1 git-crypt collaborator
Jul 6, 2022
37395a4
Add 1 git-crypt collaborator
Jul 6, 2022
64715d8
Add 2 git-crypt collaborators
Jul 6, 2022
04b36bf
New keys and env variables added
Jul 6, 2022
46713de
env files added & modified
Jul 7, 2022
3cbea5e
Merge from master
Jul 8, 2022
dd2e28c
Make run now uses .dev.env
Jul 8, 2022
5fbd76a
Pipeline modified
Jul 8, 2022
417fb0f
is the .env needed?
rodolfoIOET Jul 8, 2022
f98d359
using encrypted .stage.env
rodolfoIOET Jul 8, 2022
d829238
load secrets
rodolfoIOET Jul 8, 2022
f304803
adding env variables
rodolfoIOET Jul 8, 2022
d798597
scopes cannot be empty
rodolfoIOET Jul 8, 2022
71b814c
use env
rodolfoIOET Jul 8, 2022
e0557f3
using env var
rodolfoIOET Jul 8, 2022
09204b3
using env file
rodolfoIOET Jul 8, 2022
eaa95fe
adding mask
rodolfoIOET Jul 8, 2022
38b3cd8
using docker buildkit
rodolfoIOET Jul 11, 2022
c9a8046
only on tags
rodolfoIOET Jul 11, 2022
ac78df4
using buildkit directly
rodolfoIOET Jul 11, 2022
9f8f2f3
using dash source
rodolfoIOET Jul 11, 2022
4f78988
docker buildkit
rodolfoIOET Jul 11, 2022
c6ab1b4
missing folders added
rodolfoIOET Jul 11, 2022
82f58a6
nginx fix
rodolfoIOET Jul 11, 2022
0b5f089
fixing secrets
rodolfoIOET Jul 11, 2022
59dbb51
problem with double qoutes
rodolfoIOET Jul 11, 2022
6506028
fixing quotes in .stage.env
rodolfoIOET Jul 11, 2022
a3e3082
fixing secrets
rodolfoIOET Jul 11, 2022
ab39a18
loading to env
rodolfoIOET Jul 11, 2022
58f2706
quotes fixed
rodolfoIOET Jul 11, 2022
ac3c03d
replacing \r
rodolfoIOET Jul 12, 2022
103f4b4
fixing trailing \n
rodolfoIOET Jul 12, 2022
0a56877
one line expose
rodolfoIOET Jul 12, 2022
8ba2a27
fixing endpoint url
rodolfoIOET Jul 12, 2022
b7693a3
removing unnecessary jobs
rodolfoIOET Jul 12, 2022
1b62b4b
update creds
rodolfoIOET Jul 12, 2022
6b3a57c
adding with space at the end of the file
rodolfoIOET Jul 13, 2022
80278d5
merging from master
rodolfoIOET Jul 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge from master
  • Loading branch information
Marco Aguirre authored and Marco Aguirre committed Jul 6, 2022
commit 5cd8097434ecdeb361e0963fc46aa33bf9c3e6c2
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.dev.env filter=git-crypt diff=git-crypt
.dev.env filter=git-crypt diff=git-crypt
6 changes: 4 additions & 2 deletions .github/workflows/CD-time-tracker-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ jobs:

- name: Inject Secrets
env:
AUTHORITY: ${{ secrets.authority }}
API_URL: ${{ secrets.api_url }}
SCOPES: ${{ secrets.scopes }}
CLIENT_ID: ${{ secrets.client_id }}
AUTHORITY: ${{ secrets.authority }}
CLIENT_URL: ${{ secrets.client_url }}
STACK_EXCHANGE_ID: ${{ secrets.stack_exchange_id }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }}
Expand All @@ -44,7 +46,7 @@ jobs:
source .env
set +a
npm install
npm run build --prod --if-present
npm run build-legacy --if-present
cp scripts/default-static-site.js ${BUILD_PATH}

- name: 'Deploy to Azure Web App'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/CI-time-tracker-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ jobs:

- name: Inject Secrets
env:
AUTHORITY: ${{ secrets.AUTHORITY }}
API_URL : ${{ secrets.API_URL }}
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
AUTHORITY: ${{ secrets.AUTHORITY }}
CLIENT_URL : ${{ secrets.CLIENT_URL }}
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/time-tracker-ui-cd-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ jobs:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Build the docker image
run: make build_prod
run: |-
docker build \
--target production -t timetracker_ui \
--build-arg API_URL="${{secrets.API_URL_STAGE}}" \
--build-arg AUTHORITY="${{secrets.AUTHORITY}}" \
--build-arg CLIENT_ID="${{secrets.CLIENT_ID_STAGE}}" \
--build-arg CLIENT_URL="${{ secrets.CLIENT_URL_STAGE}}" \
--build-arg SCOPES="${{secrets.SCOPES}}" \
--build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING="${{secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING}}" \
.

- name: Publish docker image to stage azure container registry
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/time-tracker-ui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ jobs:

- name: Inject Secrets
env:
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
AUTHORITY: ${{ secrets.AUTHORITY }}
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
API_URL: ${{ secrets.STAGE_API_URL}}
SCOPES: ${{ secrets.SCOPES }}
CLIENT_ID: ${{ secrets.STAGE_CLIENT_ID }}
CLIENT_URL: ${{ secrets.STAGE_CLIENT_URL }}
STACK_EXCHANGE_ID: ${{ secrets.STAGE_STACK_EXCHANGE_ID }}
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STAGE_STACK_EXCHANGE_ACCESS_TOKEN }}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
run: |
chmod +x ./scripts/populate-keys.sh
Expand Down
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14 AS development
FROM node:14 AS building

ENV USERNAME timetracker
ENV HOME /home/${USERNAME}
Expand All @@ -12,21 +12,30 @@ USER ${USERNAME}
RUN npm cache clean --force && npm install
EXPOSE 4200
EXPOSE 9876
CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
ARG API_URL
ARG AUTHORITY
ARG CLIENT_ID
ARG CLIENT_URL
ARG SCOPES
ARG AZURE_APP_CONFIGURATION_CONNECTION_STRING

RUN API_URL=${API_URL} \
AUTHORITY=${AUTHORITY} \
CLIENT_ID=${CLIENT_ID} \
CLIENT_URL=${CLIENT_URL} \
SCOPES=${SCOPES} \
AZURE_APP_CONFIGURATION_CONNECTION_STRING=${AZURE_APP_CONFIGURATION_CONNECTION_STRING}



FROM development as build
COPY .env .
RUN npm run build


FROM nginx:1.21 AS production

ENV USERNAME app
RUN useradd -ms /bin/bash ${USERNAME}

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
COPY --from=building /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
COPY .env /usr/share/nginx/html
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the s
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)

.PHONY: build_prod
build_prod: ## Create docker image with dependencies needed for production.
docker build --target production -t timetracker_ui_prod -f Dockerfile .
build_prod: ## Create docker image with dependencies needed for production -- to test locally only
docker build \
--target production -t timetracker_ui_prod \
--build-arg API_URL="${API_URL}" \
--build-arg AUTHORITY="${AUTHORITY}" \
--build-arg CLIENT_ID="${CLIENT_ID}" \
--build-arg CLIENT_URL="${CLIENT_URL}" \
--build-arg SCOPES="${SCOPES}" \
--build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING="${AZURE_APP_CONFIGURATION_CONNECTION_STRING}" \
.

.PHONY: run_prod
run_prod: ## Execute timetracker_ui_prod docker container.
docker run -d -p 80:80 --env-file ./.env --name timetracker_ui_prod timetracker_ui_prod
run_prod: ## Execute timetracker_ui_prod docker container -- to test locally only
docker run -d -p 80:80 --name timetracker_ui_prod timetracker_ui_prod

.PHONY: stop_prod
stop_prod: ## Stop container timetracker_ui_prod.
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ Yo have 2 ways to run this project in dev mode:
- In your project path, open your favourite command line and run the follwing commands: `make build` then `make run` and finally `make logs`. When the project is successfully compiled you can go to `http://localhost:4200/` in your browser. Remember you must have your Docker running.

**Second**:

note: If you're on windows, use para bash to set up the environment.
- Set the environment variables executing the following commands:
```bash
set -a
source .env
set +a
```
- Run `ng serve` to run the app in dev mode. After executing this command, you can navigate to `http://localhost:4200/` to see the app working. This method is usefull when you want to run a specific branch using less time but not recommended when doing QA.

In any case, the app will automatically reload if you change anything in the source files.
Expand Down
28 changes: 28 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,34 @@
"maximumError": "10kb"
}
]
},
"productionlegacy": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prodlegacy.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
Expand Down
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ services:
- 9876:9876
environment:
AUTHORITY: ${AUTHORITY}
API_URL: ${API_URL}
CLIENT_ID: ${CLIENT_ID}
CLIENT_URL: ${CLIENT_URL}
SCOPES: ${SCOPES}
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
AUTHORITY_JSON: ${AUTHORITY_JSON}
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
SCOPES_JSON: ${SCOPES_JSON}
volumes:
- ./src:/home/timetracker/time-tracker-ui/src/
- ./scripts:/home/timetracker/time-tracker-ui/scripts/
Expand All @@ -39,12 +38,11 @@ services:
- 9876:9876
environment:
CHROME_BIN: /opt/google/chrome/google-chrome
API_URL: ${API_URL}
AUTHORITY: ${AUTHORITY}
CLIENT_ID: ${CLIENT_ID}
CLIENT_URL: ${CLIENT_URL}
SCOPES: ${SCOPES}
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
AUTHORITY_JSON: ${AUTHORITY_JSON}
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
SCOPES_JSON: ${SCOPES_JSON}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"build-legacy": "ng build --configuration productionlegacy",
"test": "ng test --browsers ChromeHeadless",
"test-headless": "ng test --browsers ChromeHeadless",
"ci-test": "ng test --no-watch --no-progress --browsers ChromeHeadless",
Expand Down
3 changes: 3 additions & 0 deletions scripts/populate-keys.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

> .env
echo "API_URL='$API_URL'" >> .env
echo "AUTHORITY='$AUTHORITY'" >> .env
echo "API_URL='$API_URL'" >> .env
echo "CLIENT_ID='$CLIENT_ID'" >> .env
echo "CLIENT_URL='$CLIENT_URL'" >> .env
echo "SCOPES='$SCOPES'" >> .env
echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env
echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env
Expand Down
9 changes: 4 additions & 5 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import { ProjectEffects } from './modules/customer-management/components/project
import { TechnologyEffects } from './modules/shared/store/technology.effects';
import { ProjectTypeEffects } from './modules/customer-management/components/projects-type/store/project-type.effects';
import { reducers, metaReducers } from './reducers';
import { environment } from '../environments/environment';
import { CLIENT_URL, environment } from '../environments/environment';
import { EnvironmentType } from '../environments/enum';
import { CustomerComponent } from './modules/customer-management/pages/customer.component';
// tslint:disable-next-line: max-line-length
import { CustomerListComponent } from './modules/customer-management/components/customer-info/components/customer-list/customer-list.component';
Expand Down Expand Up @@ -168,7 +169,7 @@ const maskConfig: Partial<IConfig> = {
StoreModule.forRoot(reducers, {
metaReducers,
}),
!environment.production
environment.production === EnvironmentType.TT_DEV
? StoreDevtoolsModule.instrument({
maxAge: 15, // Retains last 15 states
})
Expand Down Expand Up @@ -206,9 +207,7 @@ const maskConfig: Partial<IConfig> = {
providers: [
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider(
'565556796659-hscrj9e6m2krc41cfng898793ocfnb8j.apps.googleusercontent.com'
)
provider: new GoogleLoginProvider(CLIENT_URL)
}
]
} as SocialAuthServiceConfig,
Expand Down
4 changes: 3 additions & 1 deletion src/app/guards/login-guard/login.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { Router, CanActivate } from '@angular/router';
import { AzureAdB2CService } from '../../modules/login/services/azure.ad.b2c.service';
import { LoginService } from '../../modules/login/services/login.service';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';


@Injectable({
providedIn: 'root',
})
export class LoginGuard implements CanActivate {
isProduction = environment.production;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
constructor(
private azureAdB2CService: AzureAdB2CService,
private router: Router,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';

@Component({
selector: 'app-activities-management',
Expand All @@ -11,6 +12,6 @@ export class ActivitiesManagementComponent implements OnInit {
showOptionInDevelopment = true;

ngOnInit() {
this.showOptionInDevelopment = !environment.production;
this.showOptionInDevelopment = environment.production === EnvironmentType.TT_DEV;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../../../../../../environments/environment';
import { EnvironmentType } from '../../../../../../../environments/enum';
import { Project } from '../../../../../shared/models';

@Injectable({
Expand All @@ -10,7 +11,7 @@ import { Project } from '../../../../../shared/models';
export class ProjectService {
projects: Project[] = [];
url = `${environment.timeTrackerApiUrl}/projects`;
isDevelopment = !environment.production;
isDevelopment = environment.production === EnvironmentType.TT_DEV;

constructor(private http: HttpClient) {}

Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { LoadUser } from 'src/app/modules/user/store/user.actions';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';
import { AzureAdB2CService } from '../login/services/azure.ad.b2c.service';
import { LoginService } from '../login/services/login.service';

Expand All @@ -11,7 +12,7 @@ import { LoginService } from '../login/services/login.service';
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit {
isProduction = environment.production;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
constructor(
private azureAdB2CService: AzureAdB2CService,
private loginService: LoginService,
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FeatureToggleCookiesService } from '../shared/feature-toggles/feature-t

import { SocialAuthService, SocialUser } from 'angularx-social-login';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';
import { LoginService } from './services/login.service';
@Component({
selector: 'app-login',
Expand All @@ -13,7 +14,7 @@ import { LoginService } from './services/login.service';
})
export class LoginComponent implements OnInit {
socialUser: SocialUser;
isProduction = environment.production;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;

constructor(
private azureAdB2CService: AzureAdB2CService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { UserInfoService } from 'src/app/modules/user/services/user-info.service
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
import { LoginService } from '../../../login/services/login.service';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';

@Component({
selector: 'app-sidebar',
templateUrl: './sidebar.component.html',
Expand All @@ -16,7 +18,7 @@ export class SidebarComponent implements OnInit, OnDestroy {
itemsSidebar: ItemSidebar[] = [];
navStart;
sidebarItems$: Subscription;
isProduction = environment.production;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;

constructor(
private router: Router,
Expand Down
3 changes: 2 additions & 1 deletion src/app/modules/shared/components/user/user.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { environment } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
import { LoginService } from '../../../login/services/login.service';

Expand All @@ -11,7 +12,7 @@ import { LoginService } from '../../../login/services/login.service';
export class UserComponent implements OnInit {
userName: string;
userEmail: string;
isProduction = environment.production;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;

constructor(private azureAdB2CService: AzureAdB2CService, private loginService: LoginService) {}

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.