From df7d85331a9d00e0bf980a39cadc553ffcf16be0 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 05:19:26 -0400 Subject: [PATCH 01/32] update to config --- .circleci/config.ch9.yml | 83 -------- .circleci/config.docker-integration.yml | 61 ------ .circleci/config.yml | 242 +++++------------------- 3 files changed, 43 insertions(+), 343 deletions(-) delete mode 100644 .circleci/config.ch9.yml delete mode 100644 .circleci/config.docker-integration.yml diff --git a/.circleci/config.ch9.yml b/.circleci/config.ch9.yml deleted file mode 100644 index 32637dd5..00000000 --- a/.circleci/config.ch9.yml +++ /dev/null @@ -1,83 +0,0 @@ -version: 2.1 -orbs: - coveralls: coveralls/coveralls@1.0.4 -jobs: - build: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - checkout - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package-lock.json" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: npm ci - - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - # because we use "npm ci" to install NPM dependencies - # we cache "~/.npm" folder - - save_cache: - paths: - - ~/.npm - key: v1-dependencies-{{ checksum "package-lock.json" }} - - - run: npm run style - - run: npm run lint - - run: npm run build:prod - - run: npm test -- --watch=false --code-coverage - - run: npm run e2e - - - store_test_results: - path: ./test_results - - store_artifacts: - path: ./coverage - - # upload coverage report to coveralls for readme badge support - # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 - # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI - - coveralls/upload - - - run: - name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/lemon-mart - - store_artifacts: - path: dist.tar.gz - - - run: - name: Move compiled app to workspace - command: | - set -exu - mkdir -p /tmp/workspace/dist - mv dist/lemon-mart /tmp/workspace/dist/ - - persist_to_workspace: - root: /tmp/workspace - paths: - - dist/lemon-mart - deploy: - docker: - - image: circleci/node:lts - working_directory: ~/repo - steps: - - attach_workspace: - at: /tmp/workspace - - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/lemon-mart --confirm -workflows: - version: 2 - build-test-and-approval-deploy: - jobs: - - build - - hold: - type: approval - requires: - - build - filters: - branches: - only: master - - deploy: - requires: - - hold diff --git a/.circleci/config.docker-integration.yml b/.circleci/config.docker-integration.yml deleted file mode 100644 index 2b8d6981..00000000 --- a/.circleci/config.docker-integration.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: 2.1 -orbs: - aws-cli: circleci/aws-cli@0.1.19 -jobs: - build: - docker: - - image: circleci/node:lts - working_directory: ~/repo - steps: - - checkout - - setup_remote_docker - - run: - name: Execute Pipeline (Build Source -> Test -> Build Web Server) - command: | - docker build -f integration.Dockerfile . -t lemon-mart:$CIRCLE_BRANCH - mkdir -p docker-cache - docker save lemon-mart:$CIRCLE_BRANCH | gzip > docker-cache/built-image.tar.gz - - save_cache: - key: built-image-{{ .BuildNum }} - paths: - - docker-cache - - store_artifacts: - path: docker-cache/built-image.tar.gz - destination: built-image.tar.gz - - deploy: - executor: aws-cli/default - steps: - - restore_cache: - keys: - - built-image-{{ .BuildNum }} - - built-image - - setup_remote_docker - - run: - name: Sign into AWS ecr - command: $(aws ecr get-login --no-include-email --region us-east-1) - - run: - name: Push it to ECR - command: | - docker load < docker-cache/built-image.tar.gz - docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - - run: echo 'do deployment here' - -workflows: - version: 2 - build-and-deploy: - jobs: - - build - - hold: - type: approval - requires: - - build - - deploy: - requires: - - hold -# Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations -# For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ -# For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ -# For Heroku see https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-image-s -# For cache optimization read https://medium.com/@gajus/making-docker-in-docker-builds-x2-faster-using-docker-cache-from-option-c01febd8ef84 diff --git a/.circleci/config.yml b/.circleci/config.yml index df2c3267..62852bf9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,213 +1,57 @@ version: 2.1 orbs: - coveralls: coveralls/coveralls@1.0.4 - cypress: cypress-io/cypress@1 -commands: - install: - description: 'Install project dependencies' - parameters: - warm-cache: - type: boolean - default: false + aws-cli: circleci/aws-cli@1.0.0 +jobs: + build: + docker: + - image: circleci/node:lts + working_directory: ~/repo steps: - checkout - - restore_cache: - keys: - - node_modules-{{ checksum "package-lock.json" }} - - when: - condition: << parameters.warm-cache >> - steps: - - run: npm install - # Pre-build Angular modules - - run: npx ngcc --properties es2015 --async false # async false is temp CI build fix - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - save_cache: - key: node_modules-{{ checksum "package-lock.json" }} - paths: - - node_modules - - ~/.cache/Cypress - lint: - description: 'Check for code style and linting errors' - steps: - - run: npm run style - - run: npm run lint - build_and_test: - description: 'Build command that accepts Angular project name as parameter' - parameters: - project: - type: string - default: 'lemon-mart' - run-tests: - type: boolean - default: true - steps: - - run: npx ng build --prod --project << parameters.project >> - - when: - condition: << parameters.run-tests >> - steps: - - run: npx ng test --code-coverage --watch=false --project << parameters.project >> - - run: npx ng e2e << parameters.project >> - store: - description: 'Stores build_and_test artifacts' - parameters: - project: - type: string - default: 'lemon-mart' - steps: + - setup_remote_docker - run: - name: Run Cypress tests - command: 'npx cypress run --record' - - - store_test_results: - path: ./test_results + name: Execute Pipeline (Build Source -> Test -> Build Web Server) + command: | + docker build -f integration.Dockerfile . -t lemon-mart:$CIRCLE_BRANCH + mkdir -p docker-cache + docker save lemon-mart:$CIRCLE_BRANCH | gzip > docker-cache/built-image.tar.gz + - save_cache: + key: built-image-{{ .BuildNum }} + paths: + - docker-cache - store_artifacts: - path: ./coverage - - # upload coverage report to coveralls for readme badge support - # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 - # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI - - coveralls/upload + path: docker-cache/built-image.tar.gz + destination: built-image.tar.gz + deploy: + executor: aws-cli/default + steps: + - restore_cache: + keys: + - built-image-{{ .BuildNum }} + - built-image + - setup_remote_docker - run: - name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/<< parameters.project >> - - store_artifacts: - path: dist.tar.gz - + name: Sign into AWS ecr + command: $(aws ecr get-login --no-include-email --region us-east-1) - run: - name: Move compiled app to workspace + name: Push it to ECR command: | - set -exu - mkdir -p /tmp/workspace/dist - mv dist/<< parameters.project >> /tmp/workspace/dist/ - - persist_to_workspace: - root: /tmp/workspace - paths: - - dist/<< parameters.project >> - deploy_now: - description: 'Deploys project to Zeit Now --> https://now.sh' - parameters: - project: - type: string - default: 'lemon-mart' - steps: - - attach_workspace: - at: /tmp/workspace - - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/<< parameters.project >> --confirm -jobs: - initialize: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install: - warm-cache: true - default: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - lint - - build_and_test - - store - deploy: - docker: - - image: circleci/node:lts - working_directory: ~/repo - steps: - - deploy_now - - ch7: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch7' - ch8: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch8' - ch10: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch10' - ch11: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch11' - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch12' - ch13: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch13' - ch14: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch14' + docker load < docker-cache/built-image.tar.gz + docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + - run: + name: Deploy + command: npm run aws:deploy workflows: version: 2 - build-test-and-approval-deploy: + build-and-deploy: jobs: - - initialize - - default: - requires: - - initialize - - ch7: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch8: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch10: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch11: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch13: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch14: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - deploy: - requires: - - default - filters: - branches: - only: master + - build + - deploy +# Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations +# For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ +# For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ +# For Heroku see https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-image-s +# For cache optimization read https://medium.com/@gajus/making-docker-in-docker-builds-x2-faster-using-docker-cache-from-option-c01febd8ef84 From 56c01d17a865e558b4df6ef4935c6c3f8c41d781 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 05:28:50 -0400 Subject: [PATCH 02/32] style:fix --- projects/ch11/src/polyfills.ts | 1 + projects/ch12/src/polyfills.ts | 1 + projects/ch13/src/app/app-material.module.ts | 2 +- projects/ch13/src/app/app.module.ts | 24 +++++++++---------- .../ch13/src/app/login/login.component.ts | 10 ++++---- .../ch13/src/app/manager/manager.module.ts | 17 ++++++------- .../user-table/user-table.component.spec.ts | 10 ++++---- .../user-table/user-table.component.ts | 12 +++++----- projects/ch13/src/polyfills.ts | 1 + 9 files changed, 41 insertions(+), 37 deletions(-) diff --git a/projects/ch11/src/polyfills.ts b/projects/ch11/src/polyfills.ts index 6b4dcb84..21e4e418 100644 --- a/projects/ch11/src/polyfills.ts +++ b/projects/ch11/src/polyfills.ts @@ -55,6 +55,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ + import 'zone.js/dist/zone' // Included with Angular CLI. diff --git a/projects/ch12/src/polyfills.ts b/projects/ch12/src/polyfills.ts index 6b4dcb84..21e4e418 100644 --- a/projects/ch12/src/polyfills.ts +++ b/projects/ch12/src/polyfills.ts @@ -55,6 +55,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ + import 'zone.js/dist/zone' // Included with Angular CLI. diff --git a/projects/ch13/src/app/app-material.module.ts b/projects/ch13/src/app/app-material.module.ts index 692b3c7b..babb9dff 100644 --- a/projects/ch13/src/app/app-material.module.ts +++ b/projects/ch13/src/app/app-material.module.ts @@ -1,3 +1,4 @@ +import { NgModule } from '@angular/core' import { MatButtonModule } from '@angular/material/button' import { MatCardModule } from '@angular/material/card' import { MatDialogModule } from '@angular/material/dialog' @@ -9,7 +10,6 @@ import { MatSidenavModule } from '@angular/material/sidenav' import { MatSnackBarModule } from '@angular/material/snack-bar' import { MatToolbarModule } from '@angular/material/toolbar' import { MatTooltipModule } from '@angular/material/tooltip' -import { NgModule } from '@angular/core' const modules = [ MatButtonModule, diff --git a/projects/ch13/src/app/app.module.ts b/projects/ch13/src/app/app.module.ts index 134422fb..930312ef 100644 --- a/projects/ch13/src/app/app.module.ts +++ b/projects/ch13/src/app/app.module.ts @@ -1,26 +1,26 @@ -import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth' import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http' +import { NgModule } from '@angular/core' +import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth' +import { FlexLayoutModule } from '@angular/flex-layout' +import { ReactiveFormsModule } from '@angular/forms' +import { BrowserModule } from '@angular/platform-browser' +import { BrowserAnimationsModule } from '@angular/platform-browser/animations' +import { EffectsModule } from '@ngrx/effects' +import { StoreDevtoolsModule } from '@ngrx/store-devtools' import { IConfig, NgxMaskModule } from 'ngx-mask' -import { AppComponent } from './app.component' import { AppMaterialModule } from './app-material.module' import { AppRoutingModule } from './app-routing.module' +import { AppComponent } from './app.component' import { AuthHttpInterceptor } from './auth/auth-http-interceptor' -import { AuthService } from './auth/auth.service' -import { BrowserAnimationsModule } from '@angular/platform-browser/animations' -import { BrowserModule } from '@angular/platform-browser' import { CustomAuthService } from './auth/auth.custom.service' -import { EffectsModule } from '@ngrx/effects' -import { FieldErrorModule } from './user-controls/field-error/field-error.module' -import { FlexLayoutModule } from '@angular/flex-layout' +import { AuthService } from './auth/auth.service' +import { SimpleDialogComponent } from './common/simple-dialog.component' import { HomeComponent } from './home/home.component' import { LoginComponent } from './login/login.component' import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component' -import { NgModule } from '@angular/core' import { PageNotFoundComponent } from './page-not-found/page-not-found.component' -import { ReactiveFormsModule } from '@angular/forms' -import { SimpleDialogComponent } from './common/simple-dialog.component' -import { StoreDevtoolsModule } from '@ngrx/store-devtools' +import { FieldErrorModule } from './user-controls/field-error/field-error.module' export const options: Partial | (() => Partial) = { showMaskTyped: true, diff --git a/projects/ch13/src/app/login/login.component.ts b/projects/ch13/src/app/login/login.component.ts index 3cd6b897..3b12b427 100644 --- a/projects/ch13/src/app/login/login.component.ts +++ b/projects/ch13/src/app/login/login.component.ts @@ -1,14 +1,14 @@ -import { ActivatedRoute, Router } from '@angular/router' import { Component, OnDestroy, OnInit } from '@angular/core' -import { EmailValidation, PasswordValidation } from '../common/validations' import { FormBuilder, FormGroup } from '@angular/forms' +import { ActivatedRoute, Router } from '@angular/router' +import { combineLatest } from 'rxjs' import { catchError, filter, tap } from 'rxjs/operators' +import { SubSink } from 'subsink' -import { AuthService } from '../auth/auth.service' import { Role } from '../auth/auth.enum' -import { SubSink } from 'subsink' +import { AuthService } from '../auth/auth.service' import { UiService } from '../common/ui.service' -import { combineLatest } from 'rxjs' +import { EmailValidation, PasswordValidation } from '../common/validations' @Component({ selector: 'app-login', diff --git a/projects/ch13/src/app/manager/manager.module.ts b/projects/ch13/src/app/manager/manager.module.ts index 66effda3..d05a3ffe 100644 --- a/projects/ch13/src/app/manager/manager.module.ts +++ b/projects/ch13/src/app/manager/manager.module.ts @@ -1,18 +1,19 @@ -import { AppMaterialModule } from '../app-material.module' -import { AuthGuard } from '../auth/auth-guard.service' import { CommonModule } from '@angular/common' +import { NgModule } from '@angular/core' import { FlexLayoutModule } from '@angular/flex-layout' -import { ManagerComponent } from './manager.component' +import { ReactiveFormsModule } from '@angular/forms' + +import { AppMaterialModule } from '../app-material.module' +import { AuthGuard } from '../auth/auth-guard.service' +import { SharedComponentsModule } from '../shared-components.module' +import { UserResolve } from '../user/user/user.resolve' +import { UserService } from '../user/user/user.service' import { ManagerHomeComponent } from './manager-home/manager-home.component' import { ManagerMaterialModule } from './manager-material.module' import { ManagerRoutingModule } from './manager-routing.module' -import { NgModule } from '@angular/core' -import { ReactiveFormsModule } from '@angular/forms' +import { ManagerComponent } from './manager.component' import { ReceiptLookupComponent } from './receipt-lookup/receipt-lookup.component' -import { SharedComponentsModule } from '../shared-components.module' import { UserManagementComponent } from './user-management/user-management.component' -import { UserResolve } from '../user/user/user.resolve' -import { UserService } from '../user/user/user.service' import { UserTableComponent } from './user-table/user-table.component' @NgModule({ diff --git a/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts b/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts index 4988387f..b269baa4 100644 --- a/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts +++ b/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts @@ -1,12 +1,12 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing' -import { commonTestingModules, commonTestingProviders } from '../../common/common.testing' - -import { EffectsModule } from '@ngrx/effects' import { FormsModule } from '@angular/forms' -import { ManagerMaterialModule } from '../manager-material.module' +import { EffectsModule } from '@ngrx/effects' +import { of } from 'rxjs' + +import { commonTestingModules, commonTestingProviders } from '../../common/common.testing' import { User } from '../../user/user/user' +import { ManagerMaterialModule } from '../manager-material.module' import { UserTableComponent } from './user-table.component' -import { of } from 'rxjs' describe('UserTableComponent', () => { let component: UserTableComponent diff --git a/projects/ch13/src/app/manager/user-table/user-table.component.ts b/projects/ch13/src/app/manager/user-table/user-table.component.ts index 711640f1..6e07da23 100644 --- a/projects/ch13/src/app/manager/user-table/user-table.component.ts +++ b/projects/ch13/src/app/manager/user-table/user-table.component.ts @@ -1,14 +1,14 @@ import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core' -import { BehaviorSubject, Observable, Subject, merge, of } from 'rxjs' -import { IUsers, UserService } from '../../user/user/user.service' +import { FormControl } from '@angular/forms' +import { MatPaginator } from '@angular/material/paginator' import { MatSort, SortDirection } from '@angular/material/sort' +import { BehaviorSubject, Observable, Subject, merge, of } from 'rxjs' import { catchError, debounceTime, map, startWith, switchMap } from 'rxjs/operators' +import { SubSink } from 'subsink' -import { FormControl } from '@angular/forms' -import { IUser } from '../../user/user/user' -import { MatPaginator } from '@angular/material/paginator' import { OptionalTextValidation } from '../../common/validations' -import { SubSink } from 'subsink' +import { IUser } from '../../user/user/user' +import { IUsers, UserService } from '../../user/user/user.service' @Component({ selector: 'app-user-table', diff --git a/projects/ch13/src/polyfills.ts b/projects/ch13/src/polyfills.ts index 6b4dcb84..21e4e418 100644 --- a/projects/ch13/src/polyfills.ts +++ b/projects/ch13/src/polyfills.ts @@ -55,6 +55,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ + import 'zone.js/dist/zone' // Included with Angular CLI. From d37846bdd3351c882abd706a3657449ab3fa48df Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 05:30:10 -0400 Subject: [PATCH 03/32] lint fix --- projects/ch13/src/app/app.module.ts | 3 --- projects/ch13/src/app/auth/auth.factory.ts | 19 ------------------- .../user-table/user-table.component.spec.ts | 1 - 3 files changed, 23 deletions(-) delete mode 100644 projects/ch13/src/app/auth/auth.factory.ts diff --git a/projects/ch13/src/app/app.module.ts b/projects/ch13/src/app/app.module.ts index 930312ef..db9a8b63 100644 --- a/projects/ch13/src/app/app.module.ts +++ b/projects/ch13/src/app/app.module.ts @@ -1,12 +1,9 @@ import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http' import { NgModule } from '@angular/core' -import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth' import { FlexLayoutModule } from '@angular/flex-layout' import { ReactiveFormsModule } from '@angular/forms' import { BrowserModule } from '@angular/platform-browser' import { BrowserAnimationsModule } from '@angular/platform-browser/animations' -import { EffectsModule } from '@ngrx/effects' -import { StoreDevtoolsModule } from '@ngrx/store-devtools' import { IConfig, NgxMaskModule } from 'ngx-mask' import { AppMaterialModule } from './app-material.module' diff --git a/projects/ch13/src/app/auth/auth.factory.ts b/projects/ch13/src/app/auth/auth.factory.ts deleted file mode 100644 index 34584772..00000000 --- a/projects/ch13/src/app/auth/auth.factory.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { HttpClient } from '@angular/common/http' -import { AngularFireAuth } from '@angular/fire/auth' - -import { environment } from '../../environments/environment' -import { CustomAuthService } from './auth.custom.service' -import { AuthMode } from './auth.enum' -import { FirebaseAuthService } from './auth.firebase.service' -import { InMemoryAuthService } from './auth.inmemory.service' - -export function authFactory(afAuth: AngularFireAuth, httpClient: HttpClient) { - switch (environment.authMode) { - case AuthMode.InMemory: - return new InMemoryAuthService() - case AuthMode.Firebase: - return new FirebaseAuthService(afAuth) - case AuthMode.CustomServer: - return new CustomAuthService(httpClient) - } -} diff --git a/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts b/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts index b269baa4..7c0993ad 100644 --- a/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts +++ b/projects/ch13/src/app/manager/user-table/user-table.component.spec.ts @@ -1,6 +1,5 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing' import { FormsModule } from '@angular/forms' -import { EffectsModule } from '@ngrx/effects' import { of } from 'rxjs' import { commonTestingModules, commonTestingProviders } from '../../common/common.testing' From 7983a11f502d9c6de36600944a7613c9c174544b Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 06:06:43 -0400 Subject: [PATCH 04/32] fix --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 62852bf9..13730754 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,6 +31,7 @@ jobs: - built-image-{{ .BuildNum }} - built-image - setup_remote_docker + - aws-cli/setup - run: name: Sign into AWS ecr command: $(aws ecr get-login --no-include-email --region us-east-1) @@ -49,7 +50,9 @@ workflows: build-and-deploy: jobs: - build - - deploy + - deploy: + requires: + - build # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ # For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ From 87ead259570546a35b21931e58958442743dd986 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 06:21:30 -0400 Subject: [PATCH 05/32] fix --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 13730754..d981c27a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: - aws-cli/setup - run: name: Sign into AWS ecr - command: $(aws ecr get-login --no-include-email --region us-east-1) + command: eval $(aws ecr get-login) - run: name: Push it to ECR command: | From b91ed7413d7029f695aca3afc8290e9e6c0a17df Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 06:45:44 -0400 Subject: [PATCH 06/32] context --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index d981c27a..876b87be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,6 +51,7 @@ workflows: jobs: - build - deploy: + context: aws requires: - build # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations From 64934584655922b5e8316884ba121de94584c948 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 06:52:38 -0400 Subject: [PATCH 07/32] workspace --- .circleci/config.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 876b87be..c4444460 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,15 @@ jobs: - store_artifacts: path: docker-cache/built-image.tar.gz destination: built-image.tar.gz + - run: + name: Move compiled app to workspace + command: | + set -exu + mv built-image.tar.gz /tmp/workspace/ + - persist_to_workspace: + root: /tmp/workspace + paths: + - dist/lemon-mart deploy: executor: aws-cli/default @@ -30,6 +39,9 @@ jobs: keys: - built-image-{{ .BuildNum }} - built-image + - attach_workspace: + at: /tmp/workspace + - checkout - setup_remote_docker - aws-cli/setup - run: @@ -38,7 +50,7 @@ jobs: - run: name: Push it to ECR command: | - docker load < docker-cache/built-image.tar.gz + docker load < /tmp/workspace/built-image.tar.gz docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - run: From 9af64d0717e6cba5418a1400735169f689b850ea Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 07:09:52 -0400 Subject: [PATCH 08/32] fix --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c4444460..5d934107 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,11 +26,11 @@ jobs: name: Move compiled app to workspace command: | set -exu - mv built-image.tar.gz /tmp/workspace/ + mv docker-cache/built-image.tar.gz /tmp/workspace/ - persist_to_workspace: root: /tmp/workspace paths: - - dist/lemon-mart + - docker-cache deploy: executor: aws-cli/default @@ -50,7 +50,7 @@ jobs: - run: name: Push it to ECR command: | - docker load < /tmp/workspace/built-image.tar.gz + docker load < /tmp/workspace/docker-cache/built-image.tar.gz docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - run: From c3180d803350bdbf0939193d4f47df6d456278a4 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 08:00:32 -0400 Subject: [PATCH 09/32] fix --- .circleci/config.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d934107..ce147fb6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,10 +15,7 @@ jobs: docker build -f integration.Dockerfile . -t lemon-mart:$CIRCLE_BRANCH mkdir -p docker-cache docker save lemon-mart:$CIRCLE_BRANCH | gzip > docker-cache/built-image.tar.gz - - save_cache: - key: built-image-{{ .BuildNum }} - paths: - - docker-cache + - store_artifacts: path: docker-cache/built-image.tar.gz destination: built-image.tar.gz @@ -26,19 +23,14 @@ jobs: name: Move compiled app to workspace command: | set -exu + mkdir -p /tmp/workspace mv docker-cache/built-image.tar.gz /tmp/workspace/ - persist_to_workspace: root: /tmp/workspace - paths: - - docker-cache deploy: executor: aws-cli/default steps: - - restore_cache: - keys: - - built-image-{{ .BuildNum }} - - built-image - attach_workspace: at: /tmp/workspace - checkout @@ -50,7 +42,7 @@ jobs: - run: name: Push it to ECR command: | - docker load < /tmp/workspace/docker-cache/built-image.tar.gz + docker load < /tmp/workspace/built-image.tar.gz docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - run: From 03115b0c8b4dcf2cb1ae0fb3002bf98bea5b370e Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 08:12:12 -0400 Subject: [PATCH 10/32] fix to ch13 --- angular.json | 86 +++++++++---------- .../ch13/src/app/manager/manager.module.ts | 3 +- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/angular.json b/angular.json index 895f6ffc..0e0e63c6 100644 --- a/angular.json +++ b/angular.json @@ -831,42 +831,42 @@ } } }, - "ch14": { + "ch13": { "projectType": "application", "schematics": {}, - "root": "projects/ch14", - "sourceRoot": "projects/ch14/src", + "root": "projects/ch13", + "sourceRoot": "projects/ch13/src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/ch14", - "index": "projects/ch14/src/index.html", - "main": "projects/ch14/src/main.ts", - "polyfills": "projects/ch14/src/polyfills.ts", - "tsConfig": "projects/ch14/tsconfig.app.json", + "outputPath": "dist/ch13", + "index": "projects/ch13/src/index.html", + "main": "projects/ch13/src/main.ts", + "polyfills": "projects/ch13/src/polyfills.ts", + "tsConfig": "projects/ch13/tsconfig.app.json", "aot": true, "assets": [ - "projects/ch14/src/favicon.ico", - "projects/ch14/src/assets", - "projects/ch14/src/android-chrome-192x192.png", - "projects/ch14/src/favicon-16x16.png", - "projects/ch14/src/mstile-310x150.png", - "projects/ch14/src/android-chrome-512x512.png", - "projects/ch14/src/favicon-32x32.png", - "projects/ch14/src/mstile-310x310.png", - "projects/ch14/src/apple-touch-icon.png", - "projects/ch14/src/manifest.json", - "projects/ch14/src/mstile-70x70.png", - "projects/ch14/src/browserconfig.xml", - "projects/ch14/src/mstile-144x144.png", - "projects/ch14/src/safari-pinned-tab.svg", - "projects/ch14/src/mstile-150x150.png" + "projects/ch13/src/favicon.ico", + "projects/ch13/src/assets", + "projects/ch13/src/android-chrome-192x192.png", + "projects/ch13/src/favicon-16x16.png", + "projects/ch13/src/mstile-310x150.png", + "projects/ch13/src/android-chrome-512x512.png", + "projects/ch13/src/favicon-32x32.png", + "projects/ch13/src/mstile-310x310.png", + "projects/ch13/src/apple-touch-icon.png", + "projects/ch13/src/manifest.json", + "projects/ch13/src/mstile-70x70.png", + "projects/ch13/src/browserconfig.xml", + "projects/ch13/src/mstile-144x144.png", + "projects/ch13/src/safari-pinned-tab.svg", + "projects/ch13/src/mstile-150x150.png" ], "styles": [ - "projects/ch14/src/lemonmart-theme.scss", - "projects/ch14/src/styles.css" + "projects/ch13/src/lemonmart-theme.scss", + "projects/ch13/src/styles.css" ], "scripts": [] }, @@ -874,8 +874,8 @@ "production": { "fileReplacements": [ { - "replace": "projects/ch14/src/environments/environment.ts", - "with": "projects/ch14/src/environments/environment.prod.ts" + "replace": "projects/ch13/src/environments/environment.ts", + "with": "projects/ch13/src/environments/environment.prod.ts" } ], "optimization": true, @@ -904,31 +904,31 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "ch14:build" + "browserTarget": "ch13:build" }, "configurations": { "production": { - "browserTarget": "ch14:build:production" + "browserTarget": "ch13:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "ch14:build" + "browserTarget": "ch13:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "projects/ch14/src/test.ts", - "polyfills": "projects/ch14/src/polyfills.ts", - "tsConfig": "projects/ch14/tsconfig.spec.json", - "karmaConfig": "projects/ch14/karma.conf.js", - "assets": ["projects/ch14/src/favicon.ico", "projects/ch14/src/assets"], + "main": "projects/ch13/src/test.ts", + "polyfills": "projects/ch13/src/polyfills.ts", + "tsConfig": "projects/ch13/tsconfig.spec.json", + "karmaConfig": "projects/ch13/karma.conf.js", + "assets": ["projects/ch13/src/favicon.ico", "projects/ch13/src/assets"], "styles": [ - "projects/ch14/src/lemonmart-theme.scss", - "projects/ch14/src/styles.css" + "projects/ch13/src/lemonmart-theme.scss", + "projects/ch13/src/styles.css" ], "scripts": [] } @@ -937,9 +937,9 @@ "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ - "projects/ch14/tsconfig.app.json", - "projects/ch14/tsconfig.spec.json", - "projects/ch14/e2e/tsconfig.json" + "projects/ch13/tsconfig.app.json", + "projects/ch13/tsconfig.spec.json", + "projects/ch13/e2e/tsconfig.json" ], "exclude": ["**/node_modules/**"] } @@ -947,12 +947,12 @@ "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { - "protractorConfig": "projects/ch14/e2e/protractor.conf.js", - "devServerTarget": "ch14:serve" + "protractorConfig": "projects/ch13/e2e/protractor.conf.js", + "devServerTarget": "ch13:serve" }, "configurations": { "production": { - "devServerTarget": "ch14:serve:production" + "devServerTarget": "ch13:serve:production" } } } diff --git a/projects/ch13/src/app/manager/manager.module.ts b/projects/ch13/src/app/manager/manager.module.ts index d05a3ffe..deb9c47e 100644 --- a/projects/ch13/src/app/manager/manager.module.ts +++ b/projects/ch13/src/app/manager/manager.module.ts @@ -1,7 +1,7 @@ import { CommonModule } from '@angular/common' import { NgModule } from '@angular/core' import { FlexLayoutModule } from '@angular/flex-layout' -import { ReactiveFormsModule } from '@angular/forms' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { AppMaterialModule } from '../app-material.module' import { AuthGuard } from '../auth/auth-guard.service' @@ -23,6 +23,7 @@ import { UserTableComponent } from './user-table/user-table.component' SharedComponentsModule, AppMaterialModule, ManagerMaterialModule, + FormsModule, ReactiveFormsModule, FlexLayoutModule, ], From 79a438f1ba7adb4bed67a4301747d02913ada5e4 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 08:16:51 -0400 Subject: [PATCH 11/32] circle fix --- .circleci/config.yml | 3 +++ integration.Dockerfile | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ce147fb6..a37e616f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,9 +27,12 @@ jobs: mv docker-cache/built-image.tar.gz /tmp/workspace/ - persist_to_workspace: root: /tmp/workspace + paths: + - . deploy: executor: aws-cli/default + working_directory: ~/repo steps: - attach_workspace: at: /tmp/workspace diff --git a/integration.Dockerfile b/integration.Dockerfile index 359b8526..91e4144d 100644 --- a/integration.Dockerfile +++ b/integration.Dockerfile @@ -9,30 +9,30 @@ COPY . . # install dependencies and build RUN npm ci -RUN npm run style -RUN npm run lint +# RUN npm run style +# RUN npm run lint RUN npm run build:prod -FROM duluca/minimal-node-chromium:lts-alpine as tester +# FROM duluca/minimal-node-chromium:lts-alpine as tester -ENV BUILDER_SRC_DIR=/usr/src -ENV TESTER_SRC_DIR=/usr/src +# ENV BUILDER_SRC_DIR=/usr/src +# ENV TESTER_SRC_DIR=/usr/src -WORKDIR $TESTER_SRC_DIR -COPY --from=builder $BUILDER_SRC_DIR . +# WORKDIR $TESTER_SRC_DIR +# COPY --from=builder $BUILDER_SRC_DIR . -# force update the webdriver, so it runs with latest version of Chrome -RUN cd ./node_modules/protractor && npm i webdriver-manager@latest +# # force update the webdriver, so it runs with latest version of Chrome +# RUN cd ./node_modules/protractor && npm i webdriver-manager@latest -WORKDIR $TESTER_SRC_DIR +# WORKDIR $TESTER_SRC_DIR -RUN npm run test:prod -# RUN npm run test:prod:e2e +# RUN npm run test:prod +# # RUN npm run test:prod:e2e -FROM duluca/minimal-nginx-web-server:1-alpine as webserver +# FROM duluca/minimal-nginx-web-server:1-alpine as webserver -ENV BUILDER_SRC_DIR=/usr/src +# ENV BUILDER_SRC_DIR=/usr/src -COPY --from=builder $BUILDER_SRC_DIR/dist/lemon-mart /var/www -CMD 'nginx' +# COPY --from=builder $BUILDER_SRC_DIR/dist/lemon-mart /var/www +# CMD 'nginx' From 60ba1000b35e3b2ed4bc81f5613cd00afee6163a Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 08:28:41 -0400 Subject: [PATCH 12/32] no context --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a37e616f..00718162 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,7 +58,6 @@ workflows: jobs: - build - deploy: - context: aws requires: - build # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations From 64c1b516198f7ae65b1f49555a4557f3305e76ff Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 09:13:07 -0400 Subject: [PATCH 13/32] try install --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00718162..c1ddc6f9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,7 @@ jobs: at: /tmp/workspace - checkout - setup_remote_docker + - aws-cli/install - aws-cli/setup - run: name: Sign into AWS ecr From fd7dadee1ba0d07e0e78dbbebf9f2f9cc9a29b27 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:07:54 -0400 Subject: [PATCH 14/32] try another --- .circleci/config.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c1ddc6f9..e3adfc18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,17 +38,16 @@ jobs: at: /tmp/workspace - checkout - setup_remote_docker - - aws-cli/install - aws-cli/setup - - run: - name: Sign into AWS ecr - command: eval $(aws ecr get-login) - - run: - name: Push it to ECR - command: | - docker load < /tmp/workspace/built-image.tar.gz - docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + # - run: + # name: Sign into AWS ecr + # command: eval $(aws ecr get-login) + # - run: + # name: Push it to ECR + # command: | + # docker load < /tmp/workspace/built-image.tar.gz + # docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + # docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - run: name: Deploy command: npm run aws:deploy @@ -57,10 +56,15 @@ workflows: version: 2 build-and-deploy: jobs: - - build + # - build + - aws-ecr/build-and-push-image: + dockerfile: integration.Dockerfile + path: . + repo: 073020584345.dkr.ecr.us-east-1.amazonaws.com + tag: 'latest' - deploy: requires: - - build + - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ # For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ From 6186ec6f4ea9e3234000800270859eab6d8d4f10 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:19:31 -0400 Subject: [PATCH 15/32] fix orb --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e3adfc18..8d5600a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,7 @@ version: 2.1 orbs: aws-cli: circleci/aws-cli@1.0.0 + aws-ecr: circleci/aws-ecr@6.8.2 jobs: build: docker: From ddba919ab7258d2a4274d1d08b8a51e1d44314a7 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:32:30 -0400 Subject: [PATCH 16/32] mrf --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8d5600a0..5a2fa955 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,10 +59,12 @@ workflows: jobs: # - build - aws-ecr/build-and-push-image: + aws-access-key-id: ${AWS_ACCESS_KEY} + aws-secret-access-key: ${AWS_SECRET_ACCESS_KEY} dockerfile: integration.Dockerfile path: . - repo: 073020584345.dkr.ecr.us-east-1.amazonaws.com - tag: 'latest' + repo: lemon-mart + tag: 'latest,${CIRCLE_BUILD_NUM}' - deploy: requires: - aws-ecr/build-and-push-image From e842d8a7752bfa3c5f02c5a3a296352dc85658c8 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:34:53 -0400 Subject: [PATCH 17/32] fix --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a2fa955..ceb9919e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,8 +59,8 @@ workflows: jobs: # - build - aws-ecr/build-and-push-image: - aws-access-key-id: ${AWS_ACCESS_KEY} - aws-secret-access-key: ${AWS_SECRET_ACCESS_KEY} + aws-access-key-id: AWS_ACCESS_KEY + aws-secret-access-key: AWS_SECRET_ACCESS_KEY dockerfile: integration.Dockerfile path: . repo: lemon-mart From 6c56ff5a4a82acc731a19190787f002d7d55a3c3 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:46:27 -0400 Subject: [PATCH 18/32] fix --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ceb9919e..cb72633d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,8 +59,10 @@ workflows: jobs: # - build - aws-ecr/build-and-push-image: - aws-access-key-id: AWS_ACCESS_KEY - aws-secret-access-key: AWS_SECRET_ACCESS_KEY + account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com' + region: '${AWS_DEFAULT_REGION}' + aws-access-key-id: '${AWS_ACCESS_KEY}' + aws-secret-access-key: '${AWS_SECRET_ACCESS_KEY}' dockerfile: integration.Dockerfile path: . repo: lemon-mart From 210dfe15a96a6becab809b5a1626763b0471c195 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:50:01 -0400 Subject: [PATCH 19/32] try --- .circleci/config.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cb72633d..c16f30d4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,9 +40,10 @@ jobs: - checkout - setup_remote_docker - aws-cli/setup - # - run: - # name: Sign into AWS ecr - # command: eval $(aws ecr get-login) + - run: + name: Sign into AWS ecr + command: eval $(aws ecr get-login) + - run: aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 073020584345.dkr.ecr.us-east-1.amazonaws.com/lemon-mart # - run: # name: Push it to ECR # command: | @@ -58,18 +59,18 @@ workflows: build-and-deploy: jobs: # - build - - aws-ecr/build-and-push-image: - account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com' - region: '${AWS_DEFAULT_REGION}' - aws-access-key-id: '${AWS_ACCESS_KEY}' - aws-secret-access-key: '${AWS_SECRET_ACCESS_KEY}' - dockerfile: integration.Dockerfile - path: . - repo: lemon-mart - tag: 'latest,${CIRCLE_BUILD_NUM}' + # - aws-ecr/build-and-push-image: + # account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com' + # region: '${AWS_DEFAULT_REGION}' + # aws-access-key-id: '${AWS_ACCESS_KEY}' + # aws-secret-access-key: '${AWS_SECRET_ACCESS_KEY}' + # dockerfile: integration.Dockerfile + # path: . + # repo: lemon-mart + # tag: 'latest,${CIRCLE_BUILD_NUM}' - deploy: - requires: - - aws-ecr/build-and-push-image + # requires: + # - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ # For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ From 1927a2ae093f1a35907414dd42637d2a3791fcf8 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 10:51:19 -0400 Subject: [PATCH 20/32] qt --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c16f30d4..5e4b0bdc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,9 +68,9 @@ workflows: # path: . # repo: lemon-mart # tag: 'latest,${CIRCLE_BUILD_NUM}' - - deploy: - # requires: - # - aws-ecr/build-and-push-image + - deploy + # requires: + # - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ # For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ From 6047fa7d59fd23320d35e35726d78cbee6d39dff Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 17:50:52 -0400 Subject: [PATCH 21/32] config aws --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5e4b0bdc..beea4cde 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,6 +40,9 @@ jobs: - checkout - setup_remote_docker - aws-cli/setup + aws-access-key-id: AWS_ACCESS_KEY + aws-secret-access-key: AWS_SECRET_ACCESS_KEY + aws-region: us-east-1 - run: name: Sign into AWS ecr command: eval $(aws ecr get-login) From 16f7ece14ebaa7e513d89f52fa0616876f9889fb Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 17:53:35 -0400 Subject: [PATCH 22/32] fux --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index beea4cde..6c85953f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ jobs: at: /tmp/workspace - checkout - setup_remote_docker - - aws-cli/setup + - aws-cli/setup: aws-access-key-id: AWS_ACCESS_KEY aws-secret-access-key: AWS_SECRET_ACCESS_KEY aws-region: us-east-1 From b434f07a8d7b760d9d183f6296cb3680d672cf27 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 17:56:19 -0400 Subject: [PATCH 23/32] fix --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c85953f..b49e11bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: - aws-cli/setup: aws-access-key-id: AWS_ACCESS_KEY aws-secret-access-key: AWS_SECRET_ACCESS_KEY - aws-region: us-east-1 + aws-region: AWS_REGION - run: name: Sign into AWS ecr command: eval $(aws ecr get-login) From 7e603e9749c2338a63fab0ce1446eb85c3e6b082 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 18:03:44 -0400 Subject: [PATCH 24/32] fix --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b49e11bf..41be6819 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,7 @@ jobs: - checkout - setup_remote_docker - aws-cli/setup: - aws-access-key-id: AWS_ACCESS_KEY + aws-access-key-id: AWS_ACCESS_KEY_ID aws-secret-access-key: AWS_SECRET_ACCESS_KEY aws-region: AWS_REGION - run: From ce5782c4236e61313956acb079b93ba820831645 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 18:09:07 -0400 Subject: [PATCH 25/32] fix --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 41be6819..01d3e8d0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,9 +40,7 @@ jobs: - checkout - setup_remote_docker - aws-cli/setup: - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-secret-access-key: AWS_SECRET_ACCESS_KEY - aws-region: AWS_REGION + context: aws - run: name: Sign into AWS ecr command: eval $(aws ecr get-login) From bcd6809996ad33761283429c36eb233941be058b Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 18:13:10 -0400 Subject: [PATCH 26/32] context --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 01d3e8d0..993db088 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,8 +39,7 @@ jobs: at: /tmp/workspace - checkout - setup_remote_docker - - aws-cli/setup: - context: aws + - aws-cli/setup - run: name: Sign into AWS ecr command: eval $(aws ecr get-login) @@ -69,7 +68,8 @@ workflows: # path: . # repo: lemon-mart # tag: 'latest,${CIRCLE_BUILD_NUM}' - - deploy + - deploy: + context: aws # requires: # - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations From 8fdb4019b56b428ddc9bd9d923dcc80149be2f32 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 18:22:29 -0400 Subject: [PATCH 27/32] test --- .circleci/config.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 993db088..9c86f88b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,6 @@ jobs: root: /tmp/workspace paths: - . - deploy: executor: aws-cli/default working_directory: ~/repo @@ -41,15 +40,15 @@ jobs: - setup_remote_docker - aws-cli/setup - run: - name: Sign into AWS ecr - command: eval $(aws ecr get-login) - - run: aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 073020584345.dkr.ecr.us-east-1.amazonaws.com/lemon-mart - # - run: - # name: Push it to ECR - # command: | - # docker load < /tmp/workspace/built-image.tar.gz - # docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - # docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + name: Sign Docker into AWS ECR + command: | + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart + - run: + name: Push it to ECR + command: | + docker load < /tmp/workspace/built-image.tar.gz + docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - run: name: Deploy command: npm run aws:deploy @@ -58,7 +57,7 @@ workflows: version: 2 build-and-deploy: jobs: - # - build + - build # - aws-ecr/build-and-push-image: # account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com' # region: '${AWS_DEFAULT_REGION}' @@ -70,7 +69,8 @@ workflows: # tag: 'latest,${CIRCLE_BUILD_NUM}' - deploy: context: aws - # requires: + requires: + - build # - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ From 914f920a8d8216c6f7f1ad5f53c56e87836f3664 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 18:59:24 -0400 Subject: [PATCH 28/32] ulti fix --- .circleci/config.yml | 23 ++++++++++------------- integration.Dockerfile | 32 ++++++++++++++++---------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9c86f88b..40daa8e6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,6 @@ version: 2.1 orbs: aws-cli: circleci/aws-cli@1.0.0 - aws-ecr: circleci/aws-ecr@6.8.2 jobs: build: docker: @@ -39,6 +38,13 @@ jobs: - checkout - setup_remote_docker - aws-cli/setup + - run: npm ci + - run: + name: Restore .env files + command: | + set +H + DOT_ENV=AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID\\nAWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY + echo -e $DOT_ENV > .env - run: name: Sign Docker into AWS ECR command: | @@ -47,8 +53,9 @@ jobs: name: Push it to ECR command: | docker load < /tmp/workspace/built-image.tar.gz - docker tag my_app:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + docker image tag $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest + docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH + docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest - run: name: Deploy command: npm run aws:deploy @@ -58,20 +65,10 @@ workflows: build-and-deploy: jobs: - build - # - aws-ecr/build-and-push-image: - # account-url: '${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com' - # region: '${AWS_DEFAULT_REGION}' - # aws-access-key-id: '${AWS_ACCESS_KEY}' - # aws-secret-access-key: '${AWS_SECRET_ACCESS_KEY}' - # dockerfile: integration.Dockerfile - # path: . - # repo: lemon-mart - # tag: 'latest,${CIRCLE_BUILD_NUM}' - deploy: context: aws requires: - build - # - aws-ecr/build-and-push-image # Deployment Integrations https://circleci.com/docs/2.0/deployment-integrations # For Docker Hub deploy see https://circleci.com/docs/2.0/building-docker-images/ # For AWS ECS deploy see https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ diff --git a/integration.Dockerfile b/integration.Dockerfile index 91e4144d..359b8526 100644 --- a/integration.Dockerfile +++ b/integration.Dockerfile @@ -9,30 +9,30 @@ COPY . . # install dependencies and build RUN npm ci -# RUN npm run style -# RUN npm run lint +RUN npm run style +RUN npm run lint RUN npm run build:prod -# FROM duluca/minimal-node-chromium:lts-alpine as tester +FROM duluca/minimal-node-chromium:lts-alpine as tester -# ENV BUILDER_SRC_DIR=/usr/src -# ENV TESTER_SRC_DIR=/usr/src +ENV BUILDER_SRC_DIR=/usr/src +ENV TESTER_SRC_DIR=/usr/src -# WORKDIR $TESTER_SRC_DIR -# COPY --from=builder $BUILDER_SRC_DIR . +WORKDIR $TESTER_SRC_DIR +COPY --from=builder $BUILDER_SRC_DIR . -# # force update the webdriver, so it runs with latest version of Chrome -# RUN cd ./node_modules/protractor && npm i webdriver-manager@latest +# force update the webdriver, so it runs with latest version of Chrome +RUN cd ./node_modules/protractor && npm i webdriver-manager@latest -# WORKDIR $TESTER_SRC_DIR +WORKDIR $TESTER_SRC_DIR -# RUN npm run test:prod -# # RUN npm run test:prod:e2e +RUN npm run test:prod +# RUN npm run test:prod:e2e -# FROM duluca/minimal-nginx-web-server:1-alpine as webserver +FROM duluca/minimal-nginx-web-server:1-alpine as webserver -# ENV BUILDER_SRC_DIR=/usr/src +ENV BUILDER_SRC_DIR=/usr/src -# COPY --from=builder $BUILDER_SRC_DIR/dist/lemon-mart /var/www -# CMD 'nginx' +COPY --from=builder $BUILDER_SRC_DIR/dist/lemon-mart /var/www +CMD 'nginx' From 39da81d6ea0302b7af2bb5fdec830546f4292a3d Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 19:02:58 -0400 Subject: [PATCH 29/32] fix --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 40daa8e6..6b07c8af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,11 +40,11 @@ jobs: - aws-cli/setup - run: npm ci - run: - name: Restore .env files - command: | - set +H - DOT_ENV=AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID\\nAWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY - echo -e $DOT_ENV > .env + name: Restore .env files + command: | + set +H + DOT_ENV=AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID\\nAWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY + echo -e $DOT_ENV > .env - run: name: Sign Docker into AWS ECR command: | From b9c92f4e53192c69a791d4fc220235d29c424160 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 19:23:31 -0400 Subject: [PATCH 30/32] fixage --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b07c8af..eaff91bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,6 +53,7 @@ jobs: name: Push it to ECR command: | docker load < /tmp/workspace/built-image.tar.gz + docker image tag lemon-mart:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH docker image tag $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest From 061accc3b57f4330e1c0ff63fbd9da4342b39ae2 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 19:50:31 -0400 Subject: [PATCH 31/32] refactor --- .circleci/config.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eaff91bc..feba1482 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,15 +48,16 @@ jobs: - run: name: Sign Docker into AWS ECR command: | - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart + ECR_URI=$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_URI - run: name: Push it to ECR command: | docker load < /tmp/workspace/built-image.tar.gz - docker image tag lemon-mart:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - docker image tag $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest - docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:$CIRCLE_BRANCH - docker image push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart:latest + docker image tag lemon-mart:$CIRCLE_BRANCH $ECR_URI:$CIRCLE_BRANCH + docker image tag $ECR_URI:$CIRCLE_BRANCH $ECR_URI:latest + docker image push $ECR_URI:$CIRCLE_BRANCH + docker image push $ECR_URI:latest - run: name: Deploy command: npm run aws:deploy From f1c0e4ca4d893a8661b4f7ca9f39d9291dd548bb Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Tue, 28 Apr 2020 20:11:09 -0400 Subject: [PATCH 32/32] refactor fix --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index feba1482..2f98565c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,12 +48,12 @@ jobs: - run: name: Sign Docker into AWS ECR command: | - ECR_URI=$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_URI + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart - run: name: Push it to ECR command: | docker load < /tmp/workspace/built-image.tar.gz + ECR_URI=$AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/lemon-mart docker image tag lemon-mart:$CIRCLE_BRANCH $ECR_URI:$CIRCLE_BRANCH docker image tag $ECR_URI:$CIRCLE_BRANCH $ECR_URI:latest docker image push $ECR_URI:$CIRCLE_BRANCH