New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging and production environment variables #223

Open
tazmaniax opened this Issue May 30, 2016 · 5 comments

Comments

Projects
None yet
6 participants
@tazmaniax

tazmaniax commented May 30, 2016

Hi,

How do I pass to s3_website on the command line whether it's staging or production environment so that it picks up the dotenv .env.staging or .env.production files respectively? I can't see anything in the documentation.

thanks

@laurilehmijoki

This comment has been minimized.

@bfred-it

This comment has been minimized.

bfred-it commented Jun 30, 2016

I feel that it would be easier to just have something like --config s3_staging.yml, this way I don't have to create a folder just for a separate configuration

@ColDog

This comment has been minimized.

ColDog commented Aug 11, 2016

This would also be a big help for me too, I will have a separate config for staging/demo that I would prefer to not store in a separate file. Not at all a showstopper as everything else has worked beautifully.

@jeromedalbert

This comment has been minimized.

jeromedalbert commented Apr 13, 2017

FYI, and in the meantime, I've had good success with this hack in s3_website.yml:

<%
  if ENV['ENV'] == 'production'
    @s3_bucket = '...'
    @cloudfront_id = '...'
  else
    @s3_bucket = '...'
    @cloudfront_id = '...'
  end
%>

...

s3_bucket: <%= @s3_bucket %>

...

cloudfront_distribution_id: <%= @cloudfront_id %>

...

And then you do ENV=production s3_website push or ENV=staging s3_website push

@theramiyer

This comment has been minimized.

theramiyer commented Jan 4, 2018

Hey! Thank you for that.

In case I don't have a CloudFront distribution for the staging environment, would the following work?

<%
  if ENV['ENV'] == 'production'
    @s3_bucket = 'prod.doma.in'
    @cloudfront = 'D1S3BUT10NID'
    @wildcardinv = true
  elsif ENV['ENV'] == 'staging'
    @s3_bucket = 'staging.doma.in'
  else
    @s3_bucket = 'dev.doma.in'
  end
%>
s3_bucket: <%= @s3_bucket %>
cloudfront_distribution_id: <%= @cloudfront %>
cloudfront_wildcard_invalidation: <%= @wildcardinv %>

That would essentially return null values for the distribution and wildcard invalidation on non-production builds. Is that valid?

I've posted this question on StackOverflow as well.

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