Initial import
authorPaul Tötterman <paul.totterman@iki.fi>
Mon, 22 Feb 2016 14:02:48 +0000 (16:02 +0200)
committerDenis Ovsienko <denis@ovsienko.info>
Sat, 18 Jul 2020 21:05:40 +0000 (22:05 +0100)
racktables-docker/.gitignore [new file with mode: 0644]
racktables-docker/Dockerfile [new file with mode: 0644]
racktables-docker/README.md [new file with mode: 0644]
racktables-docker/docker-compose.yml [new file with mode: 0644]
racktables-docker/entrypoint.sh [new file with mode: 0644]
racktables-docker/nginx.conf [new file with mode: 0644]

diff --git a/racktables-docker/.gitignore b/racktables-docker/.gitignore
new file mode 100644 (file)
index 0000000..d38c149
--- /dev/null
@@ -0,0 +1,2 @@
+*.swp
+*~
diff --git a/racktables-docker/Dockerfile b/racktables-docker/Dockerfile
new file mode 100644 (file)
index 0000000..dda5ccd
--- /dev/null
@@ -0,0 +1,27 @@
+# vim: set ft=dockerfile:
+FROM alpine:latest
+# Author with no obligation to maintain
+MAINTAINER Paul Tötterman <paul.totterman@iki.fi>
+
+ENV DBHOST="mariadb" \
+    DBNAME="racktables" \
+    DBUSER="racktables" \
+    DBPASS=""
+
+COPY entrypoint.sh /entrypoint.sh
+RUN apk --no-cache add php-fpm php-gd php-pdo_mysql php-ldap php-snmp php-pcntl php-json php-bcmath php-curl \
+    && chmod +x /entrypoint.sh \
+    && wget -O /racktables.tar.gz 'http://downloads.sourceforge.net/project/racktables/RackTables-0.20.11.tar.gz?r=&ts=1456138604&use_mirror=netassist' \
+    && mkdir /opt \
+    && tar -xz -C /opt -f /racktables.tar.gz \
+    && mv /opt/RackTables-0.20.11 /opt/racktables \
+    && rm -f /racktables.tar.gz \
+    && sed -i \
+    -e 's|^listen =.*$|listen = 9000|' \
+    -e 's|^;daemonize =.*$|daemonize = no|' \
+    /etc/php/php-fpm.conf
+
+VOLUME /opt/racktables/wwwroot
+EXPOSE 9000
+ENTRYPOINT ["/entrypoint.sh"]
+CMD ["/usr/bin/php-fpm"]
diff --git a/racktables-docker/README.md b/racktables-docker/README.md
new file mode 100644 (file)
index 0000000..661e089
--- /dev/null
@@ -0,0 +1,11 @@
+# Quickstart
+
+Note that this isn't a production setup, but fairly close. Make sure to change
+the configuration if you intend to use it in production.
+
+    docker-compose up
+    # Start by browsing to http://localhost/?module=installer&step=5
+
+# Configuration
+
+Look at the env vars available in the `Dockerfile` and `entrypoint.sh`.
diff --git a/racktables-docker/docker-compose.yml b/racktables-docker/docker-compose.yml
new file mode 100644 (file)
index 0000000..09160da
--- /dev/null
@@ -0,0 +1,26 @@
+mariadb:
+  image: mariadb
+  environment:
+  - MYSQL_DATABASE=racktables
+  - MYSQL_USER=racktables
+  - MYSQL_PASSWORD=foobarbaz
+  - MYSQL_RANDOM_ROOT_PASSWORD=yes_since_this_isnt_production
+racktables:
+  build: .
+  links:
+  - mariadb
+  environment:
+  - DBHOST=mariadb
+  - DBNAME=racktables
+  - DBUSER=racktables
+  - DBPASS=foobarbaz
+nginx:
+  image: nginx
+  links:
+  - racktables
+  volumes_from:
+  - racktables
+  volumes:
+  - ./nginx.conf:/etc/nginx/nginx.conf
+  ports:
+  - 8000:80
diff --git a/racktables-docker/entrypoint.sh b/racktables-docker/entrypoint.sh
new file mode 100644 (file)
index 0000000..a583548
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+: "${DBNAME:=racktables}"
+: "${DBHOST:=mariadb}"
+: "${DBUSER:=racktables}"
+
+if [ ! -e /opt/racktables/wwwroot/inc/secret.php ]; then
+    cat > /opt/racktables/wwwroot/inc/secret.php <<EOF
+<?php
+\$pdo_dsn = 'mysql:host=${DBHOST};dbname=${DBNAME}';
+\$db_username = '${DBUSER}';
+\$db_password = '${DBPASS}';
+\$user_auth_src = 'database';
+\$require_local_account = TRUE;
+# See https://wiki.racktables.org/index.php/RackTablesAdminGuide
+?>
+EOF
+fi
+
+chmod 0400 /opt/racktables/wwwroot/inc/secret.php
+chown nobody:nogroup /opt/racktables/wwwroot/inc/secret.php
+
+echo 'To initialize the db, first go to /?module=installer&step=5'
+
+exec "$@"
diff --git a/racktables-docker/nginx.conf b/racktables-docker/nginx.conf
new file mode 100644 (file)
index 0000000..b519dc3
--- /dev/null
@@ -0,0 +1,37 @@
+# vim: set ft=nginx:
+user  nginx;
+worker_processes  1;
+
+error_log /dev/stderr warn;
+pid /var/run/nginx.pid;
+
+events {
+    worker_connections 1024;
+}
+
+http {
+    include /etc/nginx/mime.types;
+    default_type application/octet-stream;
+    access_log /dev/stdout combined;
+    sendfile on;
+    keepalive_timeout 65;
+
+    server {
+        listen 80 default_server;
+        server_name _;
+
+        root /opt/racktables/wwwroot;
+
+        location / {
+            index index.php;
+        }
+
+        location ~ \.php$ {
+            try_files $uri =404;
+            fastcgi_pass racktables:9000;
+            fastcgi_index index.php;
+            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+            include /etc/nginx/fastcgi_params;
+        }
+    }
+}