Skip to content

Instantly share code, notes, and snippets.

@mwkorver
Created June 1, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwkorver/bc493dc2ad3b49c6e5844ec162a6bffd to your computer and use it in GitHub Desktop.
Save mwkorver/bc493dc2ad3b49c6e5844ec162a6bffd to your computer and use it in GitHub Desktop.
dockerized mapserver
#cloud-boothook
#!/bin/bash
set -x
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
# fix for "unable to resolve host" error even when dns hostnames/resolution are turned on for VPC
echo "127.0.0.1 $(hostname)" >> /etc/hosts
# copy shapefiles from S3 bucket
aws s3 sync s3://umgeocon/shpfl /home/ec2-user/mapfiles
# copy map file, this file includes keys
aws s3 cp s3://umgeocon/mapfiles/test.map /home/ec2-user/mapfiles/test.map
if [ -x "$(command -v docker)" ]
then
echo "This is a reboot"
else
echo "Running first time install scripts."
yum update -y
DEBIAN_FRONTEND=noninteractive
# install docker
yum install -y docker
service docker start
docker run --detach -v /home/ec2-user/mapfiles:/mapfiles:ro --publish 8080:80 --name mapserver geodata/mapserver
# log file setup in the now running mapserver container
# the location of the log file is dependent on what you specify in your map file.
# looks like - CONFIG "MS_ERRORFILE" "/var/log/ms_error.log" in map file
docker exec mapserver touch /var/log/ms_error.log
docker exec mapserver chown www-data /var/log/ms_error.log
docker exec mapserver chmod 644 /var/log/ms_error.log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment