From 447597b665286350caf058d9275031c136f34e74 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 22 Jan 2015 15:12:18 -0800 Subject: [PATCH] add Dockerfile support --- Dockerfile | 73 +++++++++++++++++++++++++++++++++ INSTALL.debian | 15 +------ script/install/supervisord_conf | 17 ++++++++ 3 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 Dockerfile create mode 100644 script/install/supervisord_conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8600759d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,73 @@ +FROM debian:wheezy + +ENV RUBY_VERSION 2.1.5 +ENV GITHUB_INSTALL https://raw.githubusercontent.com/r888888888/danbooru/master/script/install +ENV POSTGRESQL_VERSION 9.1 + +RUN apt-get update +RUN apt-get -y \ + install \ + build-essential \ + automake \ + libssl-dev \ + libxml2-dev \ + libxslt-dev \ + ncurses-dev \ + sudo \ + libreadline-dev \ + flex \ + bison \ + ragel \ + memcached \ + libmemcache-dev \ + git \ + curl \ + libcurl4-openssl-dev \ + imagemagick \ + libmagickcore-dev \ + libmagickwand-dev \ + sendmail-bin \ + sendmail \ + postgresql \ + postgresql-contrib \ + libpq-dev \ + nginx \ + ssh \ + openssh-server \ + supervisor +RUN useradd -m danbooru +RUN chsh -s /bin/bash danbooru +RUN usermod -G danbooru,sudo danbooru + +USER danbooru +RUN git clone git://github.com/sstephenson/rbenv.git ~/.rbenv +RUN touch ~/.bash_profile +RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +RUN echo 'eval "$(rbenv init -)"' >> ~/.bash_profile +RUN mkdir -p ~/.rbenv/plugins +RUN git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +RUN ["/bin/bash", "-l", "-c", "rbenv install $RUBY_VERSION"] +RUN ["/bin/bash", "-l", "-c", "rbenv global $RUBY_VERSION"] +RUN mkdir ~/.danbooru +RUN openssl rand -hex 32 > ~/.danbooru/secret_token +RUN openssl rand -hex 32 > ~/.danbooru/session_secret_key +RUN chmod 600 ~/.danbooru/* +RUN ["/bin/bash", "-l", "-c", "gem install --no-ri --no-rdoc bundler"] + +USER root +ADD $GITHUB_INSTALL/postgresql_hba_conf /etc/postgresql/$POSTGRESQL_VERSION/main/pg_hba.conf +RUN chmod 644 /etc/postgresql/$POSTGRESQL_VERSION/main/pg_hba.conf +ADD $GITHUB_INSTALL/nginx.danbooru.conf /etc/nginx/conf.d/danbooru.conf +RUN chmod 644 /etc/nginx/conf.d/danbooru.conf +RUN sed -i -e "s/__hostname__/$HOSTNAME/g" /etc/nginx/conf.d/danbooru.conf +ADD $GITHUB_INSTALL/danbooru_logrotate_conf /etc/logrotate.d/danbooru.conf +RUN chmod 644 /etc/logrotate.d/danbooru.conf +ADD $GITHUB_INSTALL/supervisord_conf /etc/supervisord.conf +RUN /etc/init.d/postgresql start && sudo -u postgres createuser -s danbooru && /etc/init.d/postgresql stop +RUN /etc/init.d/postgresql start && sudo -u danbooru createdb danbooru2 && /etc/init.d/postgresql stop + +USER danbooru +RUN git clone git://github.com/r888888888/danbooru.git ~/danbooru +RUN ["/bin/bash", "-l", "-c", "cd ~/danbooru && bundle install"] + +CMD supervisord -c /etc/supervisord.conf diff --git a/INSTALL.debian b/INSTALL.debian index 1aa586238..b80f86c77 100644 --- a/INSTALL.debian +++ b/INSTALL.debian @@ -20,15 +20,8 @@ if [[ -z "$HOSTNAME" ]] ; then exit 1 fi -RUBY_VERSION=1.9.3-p327 -GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install - -echo -n "* Enter a name for the site (default: Danbooru): " -read SITENAME - -if [[ -z "$SITENAME" ]] ; then - SITENAME=Danbooru -fi +export RUBY_VERSION=2.1.5 +export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install # Install packages echo "* Installing packages..." @@ -98,10 +91,6 @@ sudo -u danbooru bash -l -c 'cd ~/danbooru ; bundle' echo "* Creating a new local git branch called develop" sudo -u danbooru bash -l -c 'cd ~danbooru ; git checkout -b develop' -echo "* Setting up known_hosts for localhost" -ssh-keyscan -t rsa,dsa localhost 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts -cat ~/.ssh/tmp_hosts >> ~/.ssh/known_hosts - echo "* Almost done! The code has been checked out at ~danbooru/danbooru. You can " echo "* now login as the danbooru user and run the following commands to deploy to " echo "* the server:" diff --git a/script/install/supervisord_conf b/script/install/supervisord_conf new file mode 100644 index 000000000..89cbb51a7 --- /dev/null +++ b/script/install/supervisord_conf @@ -0,0 +1,17 @@ +[supervisord] +nodaemon=true + +[program:sshd] +command=/etc/init.d/sshd start + +[program:nginx] +command=/etc/init.d/nginx start + +[program:postgresql] +command=/etc/init.d/postgresql start + +[program:memcached] +command=/etc/init.d/memcached start + +[program:crond] +command=/etc/init.d/crond start