diff --git a/.gitignore b/.gitignore index 337f192..1d5da34 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,6 @@ remotefiles/ *.sqlite dev_settings.py *.log -*.vagrant \ No newline at end of file +*.vagrant +mongodb +caddy diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..2cfff1b --- /dev/null +++ b/Caddyfile @@ -0,0 +1,8 @@ +http://example.com { + tls self_signed + root /srv + proxy / http://amon:8000 { + transparent + except /static + } +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b850542 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM frolvlad/alpine-python3 + +# Install all required dependencies +RUN apk add --no-cache gcc yaml-dev libev-dev git gcc g++ make libffi-dev openssl-dev +RUN apk add --no-cache python3-dev + +# Create the directories where you are going to store the configs, logs and Amon itself +RUN mkdir -p /opt/amon +RUN mkdir -p /var/log/amon +RUN mkdir -p /etc/opt/amon + +# Clone repo into app directory +RUN git clone https://github.com/amonapp/amon.git /opt/amon + +# Install Python deps +RUN pip install -r /opt/amon/requirements.txt + +# Setup Unicorn +COPY gunicorn.conf /opt/amon/gunicorn.conf + +# Copy defaults and setup working directroy +COPY amon-defaults.yml /etc/opt/amon/amon.yml +WORKDIR /opt/amon + +# Run the database migrations and cron install tasks +RUN python3 manage.py migrate +RUN python3 manage.py installtasks + +# Setup external volumes +VOLUME ["/opts/amon", "/var/log/amon", "/etc/opt/amon"] + +# Setup Ports +EXPOSE 8000 + +# Start webserver +CMD gunicorn wsgi -c /opt/amon/gunicorn.conf \ No newline at end of file diff --git a/amon-defaults.yml b/amon-defaults.yml new file mode 100644 index 0000000..3400514 --- /dev/null +++ b/amon-defaults.yml @@ -0,0 +1,9 @@ +host: http://example.com +mongo_uri: mongodb://mongodb:27017 +smtp: + host: smtp.mailgun.org + port: 587 + username: amon_alerts + password: amon_password + use_tls: true + sent_from: alerts@yourdomain.com \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3547e25 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '2' +services: + caddy: + image: abiosoft/caddy + restart: always + ports: + - "80:80" + - "443:443" + volumes: + - "./Caddyfile:/etc/Caddyfile" + - "./caddy:/root/.caddy" + - "./amon/static:/srv/static" + links: + - "amon:amon" + depends_on: + - "amon" + mongodb: + image: "mongo" + restart: always + expose: + - "27017" + volumes: + - "./mongodb:/data/db:rw" + amon: + build: "." + restart: always + expose: + - "8000" + links: + - "mongodb:mongodb" + depends_on: + - "mongodb" \ No newline at end of file