I've changed the meta tags in my index.html. But this is not updating in amplify. I have a git connection that auto-builds...why is not pulling these changes from git when it builds and deploys?
Related
I have a simple javascript projet created using npm. The source code is in a public github repository.
Here is the content of the repository
my-project
src
index.html
app.js
package.json
README.md
In my local environment I run it using lite-server by executing npm run dev.
I create gh-pages branch from my main branch, my code was automatically deployed after but when I visit the page it show the content of the README.md file.
How can I point to my index.html page instead so that my simple website is rendered ?
Do I have to absolutely move my index.html to the root directory ? Or is there other way without changing my project folder structre ?
=============== MY SOLUTION ===============
I just had to copy index.html and app.js at the root of the branch gh-pages.
You can only choose the root folder or /docs from repo settings.
https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site
Basically I'm structuring my app similar to this GitHub project:
https://github.com/zackargyle/angularjs-django-rest-framework-seed
Is it possible to deploy both the backend and frontend onto a single PaaS such as Heroku/Elastic Beanstalk?
Having a separated REST backend and JavaScript frontend seems like a cleaner/more scalable way to do things rather than trying to mix them together like [django-angular]: (http://django-angular.readthedocs.org/en/latest/index.html/), or having a REST backend mix with the Django app like http://blog.mourafiq.com/post/55099429431/end-to-end-web-app-with-django-rest-framework
If it is not possible to deploy it easily onto Elastic Beanstalk, is there an easy way to deploy the Django backend onto Elastic Beanstalk, and AngularJS frontend to Amazon EC2/S3 with minimal configuration?
I realize there's a similar discussion before this: Client JS + Django Rest Framework
but it lacks more specific details.
I'm in the exact same boat with AngularJS as my client and django-rest-framework as my service. I also have the same type of git setup where the server and client code are siblings in the same repository. I don't have any experience with Heroku and I'm new to beanstalk but I was able to deploy my site and it's working on AWS beanstalk.
With beanstalk there are two ways I know of to deploy your code.
Use eb and git described here.
Works well if you want to push your source code directly.
Create your own zip to upload to beanstalk via the AWS management console. Amazon has a walkthrough on it here.
Route I chose so I can 'grunt build' my client and zip with server code before deploying.
I automated the zip creation using a python script. Amazon's walkthrough provides an example python zip. You have to structure it properly, mine looks roughly like this
app.zip
/.ebextensions/
/.elasticbeanstalk/
/app/ <-- my django-rest-framework project (settings.py, wsgi.py, etc.)
/restapi/ <-- my django-rest-framework application (my api)
/static/ <-- AngularJS results of 'grunt build' put here
/manage.py
/requirements.txt
I know you didn't specifically ask but the .config file inside .ebextensions/ took me way too long to get working. It can be formatted as YAML or JSON (can be confusing at first as every blog shows it differently). This blog helped me out quite a bit just be careful to use container_commands: and not commands:. I lost a few hours to that...
container_commands:
01_syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
option_settings:
"aws:elasticbeanstalk:container:python:environment":
"DJANGO_SETTINGS_MODULE": "app.settings"
"aws:elasticbeanstalk:container:python":
"WSGIPath": "app/wsgi.py"
"StaticFiles": "/static/=static/"
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
"aws:elasticbeanstalk:application:environment":
"AWS_SECRET_KEY": "<put your secret key here if you want to reference from env variable>"
"AWS_ACCESS_KEY_ID": "<put your access key here>"
"AWS_S3_Bucket": "<put your bucket here>"
In the zip you create (if you follow the beanstalk guides on django) the client code in your /static/ folder is automatically pushed to s3 when you deploy.
This setup isn't perfect and I plan on fine tuning things but it's working. Here are some downsides I ran into that I haven't solved yet:
Since I put my client code in the static/ folder my site sits under mysite.com/static/. Ideally I'd want it to be served as the root at mysite.com with my django-rest-framework content under mysite.com/api/
If you use the self describing api on beanstalk by default the assets won't be pushed since they sit in your python directory and not with your source code.
UPDATE 4-17-2014
I further refined this setup so I no longer have to go to mysite.com/static/ to load my index.html. To do so I used a django class based view to map index.html to the root of my site. My urls.py looks like
urlpatterns = patterns('',
(r'^$', TemplateView.as_view(template_name="index.html")),
...
)
and in my settings.py I configured TEMPLATE_DIRS as follows
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__) , '../static').replace('\\','/')
)
I use ../static because my static directory is a sibling of my app directory.
The last piece was to update my Gruntfile.js so 'grunt build' prefixes all the relative URLs in my angular code with the static folder. I used grunt-text-replace for this. It's the last task that runs after my code is sitting minified in a /dist folder. The downside to this approach is I'll have to update this task if I ever add static content to a new subfolder besides scripts, bower_components, styles, etc.
replace: {
replace_js_templates: {
src: ['dist/scripts/*.js'],
overwrite: true, // overwrite matched source files
replacements: [{
from: /templateUrl:\s*"/g,
to: 'templateUrl:"static/'
}]
},
replace_index: {
src: ['dist/index.html'],
overwrite: true, // overwrite matched source files
replacements: [{
from: /(src|href)="(bower_components|styles|scripts)/g,
to: '$1="static/$2'
}
]
}
},
Now django will serve my index.html page but everything else in my /static/ directory can benefit from a CDN.
This is a basic question. The other day I was watching a video on youtube on deploying django application to heroku. In that video they went through amazon web services for static files. When I deployed django on heroku today all my static files are working. Am I missing something here?
Yeah, they have a document up on it now: https://devcenter.heroku.com/articles/django-assets
Rename your index.html to home.html.
Create an index.php file with the following code:
<?php include_once("home.html"); ?>
Now go to your app folder in CMD (or Bash), and commit your code to Heroku using the following:
git add .
git commit -m 'Change this to a meaningful description'
git push heroku master
Source
I have a media folder that stores all my uploaded images during development and I'm pushing my django(1.5.1) project to a dev server on heroku. Inside the media folder I have
media/
# cache and images were commited before .gitignored was added
cache/ # store thumbnails
images/ # store images
.gitignore
the .gitignore has
*
!.gitignore
The problem is whenever I git push to heroku, all my testing uploads are wiped out by git. Is there a way to deal with this?
This isn't an issue with Git, but rather with Heroku. Heroku's file system is ephemeral, and is reset between deploys. Use a service like Amazon S3 to store uploaded files.
I have an existing Django app on Bitbucket and I'm able to deploy to Heroku whith hg-git. Whenever i want to run some heroku command inside my app folder i get the following errors:
$ heroku ps
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
$ heroku logs
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
etc.
Current workaround is to specify the app name: heroku ps --app <app name> but i'm looking for a way to link my repository name to the remote Heroku app name like how it's done using git.
I'm not in a position to move my app to github for now.
I'd suggest trying Hg-Git's "intree" configuration option. Set that by adding the following to your hgrc:
[git]
intree = True
With that set, the Git repository used internally by Hg-Git will be stored as a ".git" directory within the working copy, rather than nested within the ".hg" directory.
Heroku will then see this repository's config. Add a remote as suggested in the other answer (quoted below), and you should be all set.
git remote add heroku git#heroku.com:<app-name>.git
For now, the best documentation of Hg-Git configuration options that I've found is the README displayed on the project's Bitbucket page: https://bitbucket.org/durin42/hg-git
Considering heroku is looking at the .git/config file to get the app name, just do the following inside your local repository:
git init
git remote add heroku git#heroku.com:<app-name>.git
In order not to mess your repository, you'll also add the following lines to .hgignore:
#Git setup
.git/**
Now, usual heroku commands no more ask for the default app name.