2

I'm following the HOWTO on deploying to Heroku: https://docs.apostrophecms.org/apostrophe/tutorials/howtos/deploying-apostrophe-in-the-cloud-with-heroku

I'm deviating from the HOWTO a bit since I'm using Heroku's mLab add-on to handle my Mongo. Also, I skipped the S3 set up for now, since I just want to get the thing up a running. I'm not sure if that's super important to the assets getting delievered appropriately.

I've completed the following from the HOWTO:

  • Created a project in Heroku
  • Added it to my git repo as heroku as a remote
  • Added mLab add-on and created a database and add the environment var pointing to that database uri.
  • Added environment vars for APOS_BUNDLE=1 and APOS_MINIFY=1
  • Added the heroku-release-scripts executable in the /scripts directory as well as the Procfile.

Here is the code from my ./scripts/heroku-release-scripts

#!/bin/bash

node app apostrophe:generation
node app apostrophe-migrations:migrate

Here is the Procfile

web: node app
release: ./scripts/heroku-release-tasks

One thing of note; If I look at the paths to my CSS and JS assets, it see something like this"

https://van-biema-partners.herokuapp.com/uploads/assets/ck0fmqn3i00050uuck7exy3v2/apos-minified/anon-ck0fmqn3i00050uuck7exy3v2.js

I'm not sure if that's correct, but maybe it is...

EDIT

Copy the above URL and remove out the '/uploads/assets/ck0fmqn3i00050uuck7exy3v2' part, I can see the CSS and JS. Not sure what's going on with the pathing, but that seems to be where the issue is, but I have no idea how to correct that. https://van-biema-partners.herokuapp.com/apos-minified/anon-ck0fmqn3i00050uuck7exy3v2.css

bgaynor78
  • 454
  • 2
  • 7
  • I might also add that I don't see any glaring in the heroku logs when the build and deploy happen. – bgaynor78 Sep 11 '19 at 16:13
  • I suspect the issue is that we missed a detail for the edge case where you haven't set up s3 yet, even though that is mandatory for real success with working uploads. The paths should be a little different in that case but it isn't actually a sustainable in between state to leave things in for most practical uses. I will open a ticket about this edge case. – Tom Boutell Sep 11 '19 at 22:15
  • Actually, I'd go so far as to say it's behaving as intended — if you actually had a working uploadfs configuration (s3 or another backend that is visible to all of your heroku dynos), it would be working fine. I will update the documentation to make clear this step is mandatory. – Tom Boutell Sep 11 '19 at 22:18
  • @TomBoutell That totally makes sense. When setting the s3, the documentation says you need to set the four evnvironment var, APOS_S3_BUCKET, APOS_S3_SECRET, APOS_S3_KEY, and APOS_S3_REGION. Is the value of the Secret and Key the access keys for my root AWS user? – bgaynor78 Sep 12 '19 at 01:53
  • You can use your root keys, yes, but Amazon will certainly plead with you to make an IAM user and an IAM group and create a policy giving access just to the bucket, so that a hacked server doesn't mean people can do exactly as they please creating AWS servers (: It's a bit of a pain though, so I won't judge you if you use the root key and secret at first. Here's info on the more secure setup: https://aws.amazon.com/blogs/security/writing-iam-policies-how-to-grant-access-to-an-amazon-s3-bucket/ – Tom Boutell Sep 12 '19 at 11:36
  • (Just in case other readers aren't sure, the "access keys" referred to here are the AWS access key id and secret available from the security credentials tab in AWS, not your username and password for logging into AWS.) – Tom Boutell Sep 12 '19 at 11:38

1 Answers1

1

The issue is that the new, simplified APOS_BUNDLE=1 functionality strictly requires that you have a persistent uploadfs back end — in other words, it requires that you set up S3, even to be successful with asset URLs.

Since this is in any case required for media uploads to work, I've fixed the documentation you read to address this requirement. I also removed a confusing leftover section about the --sync-to-uploadfs option, which is not required anymore to copy assets to S3; that is part of what led the confusing impression that S3 might not be mandatory.

(Strictly speaking it does not have to be Amazon S3. In addition to supporting alternative S3 implementations, Apostrophe's uploadfs module also supports Azure blob storage and Google's cloud storage. The uploadfs documentation has more on that topic. What is truly a requirement is somewhere other than the heroku temporary filesystem to store things, because those are not persistent, nor are the same files visible to all dynos.)

Tom Boutell
  • 7,281
  • 1
  • 26
  • 23