Skip to content

Commit cd79b15

Browse files
committed
Update Packer template and build script for Atlasification
1 parent 2b24392 commit cd79b15

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

website/packer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"variables": {
3+
"aws_access_key_id": "{{ env `AWS_ACCESS_KEY_ID` }}",
4+
"aws_secret_access_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}",
5+
"aws_region": "{{ env `AWS_REGION` }}",
6+
"fastly_api_key": "{{ env `FASTLY_API_KEY` }}"
7+
},
8+
"builders": [
9+
{
10+
"type": "docker",
11+
"image": "ruby:2.3-slim",
12+
"commit": "true"
13+
}
14+
],
15+
"provisioners": [
16+
{
17+
"type": "file",
18+
"source": ".",
19+
"destination": "/app"
20+
},
21+
{
22+
"type": "shell",
23+
"environment_vars": [
24+
"AWS_ACCESS_KEY_ID={{ user `aws_access_key_id` }}",
25+
"AWS_SECRET_ACCESS_KEY={{ user `aws_secret_access_key` }}",
26+
"AWS_REGION={{ user `aws_region` }}",
27+
"FASTLY_API_KEY={{ user `fastly_api_key` }}"
28+
],
29+
"inline": [
30+
"apt-get update",
31+
"apt-get install -y build-essential curl git libffi-dev s3cmd",
32+
"cd /app",
33+
34+
"bundle check || bundle install --jobs 7",
35+
"bundle exec middleman build",
36+
37+
"/bin/bash ./scripts/deploy.sh"
38+
]
39+
}
40+
]
41+
}

scripts/website_push.sh renamed to website/scripts/deploy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fi
3131
# directory
3232
SOURCE="${BASH_SOURCE[0]}"
3333
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
34-
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
34+
DIR="$(cd -P "$( dirname "$SOURCE" )/.." && pwd)"
3535

3636
# Upload the files to S3 - we disable mime-type detection by the python library
3737
# and just guess from the file extension because it's surprisingly more
@@ -42,8 +42,8 @@ if [ -z "$NO_UPLOAD" ]; then
4242
echo "Uploading to S3..."
4343

4444
# Check that the site has been built
45-
if [ ! -d "$DIR/website/build" ]; then
46-
echo "Missing compiled website! Running `make build` to compile!"
45+
if [ ! -d "$DIR/build" ]; then
46+
echo "Missing compiled website! Run 'make build' to compile!"
4747
exit 1
4848
fi
4949

@@ -56,7 +56,7 @@ if [ -z "$NO_UPLOAD" ]; then
5656
--recursive \
5757
--add-header="Cache-Control: max-age=31536000" \
5858
--add-header="x-amz-meta-surrogate-key: site-$PROJECT" \
59-
put "$DIR/website/build/" "s3://hc-sites/$PROJECT/latest/"
59+
put "$DIR/build/" "s3://hc-sites/$PROJECT/latest/"
6060
fi
6161

6262
# Perform a soft-purge of the surrogate key.

0 commit comments

Comments
 (0)