From 7e6ec689e868410371aed62e287edaf767d1cd66 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 4 Mar 2020 23:20:33 -0800 Subject: [PATCH] latest --- .dockerignore | 1 + .gitignore | 2 ++ Dockerfile | 31 ++++++++++++++++++++-------- Makefile | 2 +- install.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ run.sh | 46 ----------------------------------------- 6 files changed, 84 insertions(+), 55 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 install.sh delete mode 100644 run.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..397b4a7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +*.log diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfce1ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log + diff --git a/Dockerfile b/Dockerfile index 29db0fc..64512bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,14 @@ ENV DEBIAN_FRONTEND noninteractive ARG UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu +ARG RUBY_VERSION="2.6.2" +ARG NODE_VERSION="v13.10.1" +# v2.4.0, current stable as of 2020-03-04: +ARG DISCOURSE_VERSION="76b9be3f19f393a216973b791245228f2d3e92f8" + +ARG UID=61000 +ARG GID=61000 + RUN echo "deb $UBUNTU_MIRROR focal main universe restricted multiverse" > /etc/apt/sources.list.new && \ echo "deb $UBUNTU_MIRROR focal-updates main universe restricted multiverse" >> /etc/apt/sources.list.new && \ echo "deb $UBUNTU_MIRROR focal-security main universe restricted multiverse" >> /etc/apt/sources.list.new && \ @@ -13,19 +21,21 @@ mv /etc/apt/sources.list.new /etc/apt/sources.list # we only install essential system packages here -ARG SYSTEM_PACKAGES="build-essential ca-certificates git golang rsync runit software-properties-common" +ARG SYSTEM_PACKAGES="locales build-essential ca-certificates git golang rsync runit software-properties-common" RUN \ apt update && \ apt -y upgrade && \ apt -y install $SYSTEM_PACKAGES && \ - go get -v -u github.com/peterbourgon/runsvinit && \ + go get -v -u git.eeqj.de/sneak/runsvinit && \ cp /root/go/bin/runsvinit /usr/local/sbin/runsvinit && \ - rm -r /root/go + rm -r /root/go && \ + echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ + locale-gen -COPY ./root /tmp/rootoverlay -RUN rsync -avP /tmp/rootoverlay/ / && \ - rm -rf /tmp/rootoverlay +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 # prereqs for discourse RUN apt update && \ @@ -68,7 +78,12 @@ RUN apt update && \ vim \ zlib1g-dev -COPY ./run.sh /tmp/run.sh -RUN /bin/bash /tmp/run.sh && rm /tmp/run.sh +COPY ./install.sh /tmp/install.sh +RUN /bin/bash /tmp/install.sh && rm /tmp/install.sh + +COPY ./root /tmp/rootoverlay +RUN rsync -avP /tmp/rootoverlay/ / && \ + rm -rf /tmp/rootoverlay && \ + chmod +x /etc/service/*/run CMD ["/usr/local/sbin/runsvinit"] diff --git a/Makefile b/Makefile index 1b9fd6e..cb1d57b 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,4 @@ build: docker build \ -t sneak/discourse \ --build-arg UBUNTU_MIRROR="http://ubuntu.datavi.be/ubuntu" \ - . + . 2>&1 | tee -a build.log diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..a419c95 --- /dev/null +++ b/install.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +export HOME=/root + +set -e +set -x + + +H="/var/lib/discourse" +mkdir -p $H + +git clone https://github.com/discourse/discourse.git $H/app +cd $H/app +git checkout $DISCOURSE_VERSION +rm -rf .git + +cd / + +chown -R $UID:$GID $H + +groupadd \ + --system --gid $GID \ + discourse + +useradd \ + --system --gid $GID --uid $UID \ + --no-log-init --no-create-home -s /bin/false --home-dir $H \ + discourse + +apt-get -yqq update +apt install -y postgresql-common +echo -e "\n" | sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh +apt-get -yqq update +apt-get install -y postgresql-client-12 + +sudo -u discourse bash -l <> ~/.gemrc + + +source $HOME/.rvm/scripts/rvm +rvm install $RUBY_VERSION +rvm --default use $RUBY_VERSION +gem install bundler mailcatcher rake + +curl -sSL https://get.rvm.io | bash +source $HOME/.nvm/nvm.sh +nvm install $NODE_VERSION +nvm alias default $NODE_VERSION +npm install -g svgo + +cd $HOME +bundle install +" diff --git a/run.sh b/run.sh deleted file mode 100644 index ca1c39c..0000000 --- a/run.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -export HOME=/root - -set -e -set -x - -apt-get -yqq update - -curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - -curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - -curl -sSL https://get.rvm.io | bash -s stable -echo 'gem: --no-document' >> ~/.gemrc - -set +e -set +x -source /etc/profile.d/rvm.sh -rvm install 2.6.2 -rvm --default use 2.6.2 -set -e -set -x - -gem install bundler mailcatcher rake - - -# install pg10 -# ubuntu has a bootstrap script for pg repo install: -apt install -y postgresql-common -sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh - -apt-get update -apt-get install postgresql-10 pgadmin4 - -# start postgres somehow -sudo -u postgres -i -createuser --superuser -Upostgres discourse -psql -c "ALTER USER discourse WITH PASSWORD 'password';" - -curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash - -# FIXME activate nvm - -find $HOME -exit 1 - -chmod +x /etc/service/*/run