Skip to content

Can't deploy to different environments #5

Open

Description

@jrdn91

I've been trying for hours to figure out why I can't get a staging setup to deploy to a different location when I pass it as a parameter to deploy js

Is this not supported? I'm using the S3 deployment setup and have two different buckets for production and staging. I can't figure out how to get this to work. Please help

Activity

  1. duizendnegen commented on Oct 11, 2017

    @duizendnegen
    Contributor

    Hi! This is supported for sure. Running deployjs deploy -e staging would use the staging environment. In config/deploy.js you would then put something like

    if(environment === 'staging') {
        ENV["s3-index"] = {
          accessKeyId: process.env.AWS_ACCESS_ID,
          secretAccessKey: process.env.AWS_SECRET_KEY,
          bucket: "bucket",
          region: "eu-central-1",
          allowOverwrite: true
        };
    
        ENV["s3"] = {
          accessKeyId: process.env.AWS_ACCESS_ID,
          secretAccessKey: process.env.AWS_SECRET_KEY,
          bucket: "bucket",
          region: "eu-central-1",
          filePattern: '**/*.{js,css,png,gif,ico,jpg,map,xml,txt,svg,swf,eot,ttf,woff,woff2,otf,json,mp3}'
        };
      }
    

    If your staging endpoint also points to a different backend server, be sure to update the API URL depending on your framework build script.

    Let me know if this works for you.

  2. jrdn91 commented on Oct 11, 2017

    @jrdn91
    Author

    So when I run that with --verbose I see a link at the beginning...

    - Missing config: environment, using default: prod``

    And then when it runs the build...

    - building app to distusing buildEnvprod...

    And it's uploading to the correct bucket, but using the wrong environment file

    I've set up in my .angular-cli.json I list it

    "environments": {
        "dev": "environments/environment.dev.ts",
        "staging": "environments/environment.staging.ts",
        "prod": "environments/environment.prod.ts"
    }
    

    Which references a different APIUrl but when I open the different buckets in the web, both are using my production APIUrl instead of being different

  3. duizendnegen commented on Oct 12, 2017

    @duizendnegen
    Contributor

    Add the following lines inside the if block of your staging environment:

    ENV["deployjs-angular-build"] = {
      environment: 'staging'
    }
    

    Welcoming a PR for better docs on https://github.com/deployjs/deployjs-angular-build specifically for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions