App-Dapper

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    deploy:
      command: rsync -av --delete _output/ me@example.com:/var/www/site/

* **Amazon S3** uses the [AWS CLI](https://aws.amazon.com/cli/)'s
  `aws s3 sync --delete`, which uploads only what changed and removes what is
  gone, then refreshes CloudFront if you name a distribution. Set up the
  bucket for website hosting first (see [Amazon S3](#amazon-s3) below) and
  run `aws configure`.
* **GitHub Pages** commits the output to the branch, with a `.nojekyll`
  file (and `CNAME` if set), and pushes it. The branch keeps its history,
  and nothing is committed when nothing changed. In the repository's
  settings, publish Pages from that branch.

With one target, `dapper deploy` uses it; with several, name one
(`dapper deploy s3`). `--dry-run` shows what would happen without publishing
anything, and `--no-build` publishes the output directory as it is.

Credentials are never stored in `_config.yml`: S3 uses the AWS CLI's own
configuration, and GitHub Pages uses git's.

The rest of this section shows how to set up hosting, and how to publish by
hand.

## Amazon S3

It's possible to serve a static website using Amazon S3. Here's how.

1. In the AWS Console, create a bucket named after your domain (e.g.
   `mydomain.com`). Under 'Properties', enable 'Static website hosting' and
   set the 'Index document' to `index.html`.

2. New buckets block public access by default. To serve a website directly
   from the bucket, turn off 'Block public access' for it and add a bucket
   policy that allows `s3:GetObject` for everyone. Alternatively, keep the
   bucket private and put Amazon CloudFront in front of it, which also gives
   you HTTPS.

3. Optionally, create a second bucket named `www.mydomain.com` and set its
   static website hosting to 'Redirect requests' to `mydomain.com`.

4. Install and configure the [AWS CLI](https://aws.amazon.com/cli/) with
   your credentials:

       $ aws configure

5. Now any time you want to rebuild your content and push it to S3, it's a
   simple call to:

       $ dapper build
       $ aws s3 sync _output/ s3://mydomain.com --delete

    The `--delete` option removes files from the bucket that are no longer
    in `_output` (Dapper removes the output of source files you delete, so
    the two stay in step). If you upload files to the bucket independently
    of Dapper, leave `--delete` off. `dapper deploy` does all of this in
    one step.

If you use Amazon Route 53 for DNS, create an alias A record for
`mydomain.com` (and `www.mydomain.com`) that points at the bucket's website
endpoint, or at your CloudFront distribution.

To make it easy to publish to Amazon S3, one option is to create a Makefile
that encodes the publishing instructions. For example:

    S3_BUCKET=mydomain.com

    build:
    	dapper build

    clean:
    	rm -rf _output

    serve:
    	dapper serve

    publish: clean build
    	aws s3 sync _output/ s3://$(S3_BUCKET) --delete

    watch:
    	dapper watch

    .PHONY: build clean serve publish watch

## GitHub Pages

GitHub Pages is a free service that allows you to publish a static website for
free. By pushing your changes to a git repository, your website will be
automatically available on github.io. Here are the steps:

1. First, if you don’t have an account already, you should sign up for a [GitHub
   account](https://github.com/).

2. Next, create a new repository named `<username>.github.io` where you should 
   replace `<username>` with your actual Github username.

3. After that, push the contents of your `_output` directory to the new github
   repo. Steps:

       $ cd _output
       $ touch .nojekyll
       $ git init -b main
       $ git remote add origin https://github.com/<username>/<username>.github.io.git
       $ git add -A
       $ git commit -m "Initial revision"
       $ git push -u origin main

   The empty `.nojekyll` file tells GitHub Pages to publish the files as
   they are, rather than running them through Jekyll (which would skip
   files and directories that start with an underscore).
   Dapper never removes files it didn't write, so `.nojekyll` and `.git`
   survive later builds.

4. In the repository's Settings, under Pages, make sure the site is
   published from the `main` branch. Wait a few minutes, then find your new
   website at `https://<username>.github.io`.

# What Dapper Doesn't Do

Dapper is deliberately small. It does not have:



( run in 2.903 seconds using v1.01-cache-2.11-cpan-eb134014566 )