Эх сурвалжийг харах

Merge branch 'master' of github.com:teodesian/tCMS

George S. Baugh 5 жил өмнө
parent
commit
b0ab5ca168

+ 3 - 22
Dockerfile

@@ -1,34 +1,15 @@
-FROM ubuntu:latest
-ARG port=5000
+FROM troglodyne/base:latest AS tcms
 
 
+ARG port=5000
 LABEL description="tCMS: a Perl CMS by Troglodyne LLC"
 LABEL description="tCMS: a Perl CMS by Troglodyne LLC"
 
 
 EXPOSE $port/tcp
 EXPOSE $port/tcp
 
 
-USER root
-RUN useradd tcms
-RUN apt-get update
-RUN apt-get install -y make apt-utils mlocate
-
 ADD . /home/tcms
 ADD . /home/tcms
-RUN mkdir /home/tcms/.tcms
 RUN chown -R tcms /home/tcms
 RUN chown -R tcms /home/tcms
 
 
-WORKDIR /home/tcms
-
-RUN apt-get install -y locales
-RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
-ENV LANG en_US.utf8
-
-ENV DEBIAN_FRONTEND=noninteractive
-RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
-RUN apt-get install -y tzdata
-RUN dpkg-reconfigure --frontend noninteractive tzdata
-
-RUN make depend
-RUN updatedb
-
 USER tcms
 USER tcms
+
 RUN make install
 RUN make install
 RUN make reset-dummy-data
 RUN make reset-dummy-data
 CMD /usr/bin/starman -p $port www/server.psgi
 CMD /usr/bin/starman -p $port www/server.psgi

+ 25 - 0
Dockerfile.build

@@ -0,0 +1,25 @@
+FROM ubuntu:latest AS base
+
+USER root
+RUN useradd tcms
+RUN apt-get update
+RUN apt-get install -y make apt-utils mlocate
+
+ADD ./Makefile /home/tcms/Makefile
+RUN mkdir /home/tcms/.tcms
+RUN mkdir -p /home/tcms/www/scripts
+RUN chown -R tcms /home/tcms
+
+WORKDIR /home/tcms
+
+RUN apt-get install -y locales
+RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
+ENV LANG en_US.utf8
+
+ENV DEBIAN_FRONTEND=noninteractive
+RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
+RUN apt-get install -y tzdata
+RUN dpkg-reconfigure --frontend noninteractive tzdata
+
+RUN make depend
+RUN updatedb

+ 11 - 1
Makefile

@@ -5,6 +5,16 @@ install:
 	test -d data/files || mkdir data/files
 	test -d data/files || mkdir data/files
 	rm pod2htmd.tmp; /bin/true
 	rm pod2htmd.tmp; /bin/true
 
 
+.PHONY: install-service
+install-service:
+	mkdir -p ~/.config/systemd/user
+	cp service-files/systemd.unit ~/.config/systemd/user/tCMS.service
+	sed -ie 's#__REPLACEME__#$(shell pwd)#g' ~/.config/systemd/user/tCMS.service
+	systemctl --user daemon-reload
+	systemctl --user enable tCMS
+	systemctl --user start tCMS
+	loginctl enable-linger $(USER)
+
 .PHONY: test
 .PHONY: test
 test: reset-dummy-data
 test: reset-dummy-data
 	prove
 	prove
@@ -20,6 +30,6 @@ depend:
 	apt-get install -y libuuid-tiny-perl libcapture-tiny-perl libconfig-simple-perl libdbi-perl libfile-slurper-perl libfile-touch-perl
 	apt-get install -y libuuid-tiny-perl libcapture-tiny-perl libconfig-simple-perl libdbi-perl libfile-slurper-perl libfile-touch-perl
 	apt-get install -y libfile-copy-recursive-perl libxml-rss-perl libmodule-install-perl
 	apt-get install -y libfile-copy-recursive-perl libxml-rss-perl libmodule-install-perl
 	apt-get install -y libmoose-perl libmoosex-types-datetime-perl libxml-libxml-perl
 	apt-get install -y libmoose-perl libmoosex-types-datetime-perl libxml-libxml-perl
-	cpanm Mojo::File Date::Format WWW::SitemapIndex::XML WWW::Sitemap::XML HTTP::Body Pod::Html URL::Encode
+	cpanm -n Mojo::File Date::Format WWW::SitemapIndex::XML WWW::Sitemap::XML HTTP::Body Pod::Html URL::Encode
 	wget -O www/scripts/fgEmojiPicker.js https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/fgEmojiPicker.js
 	wget -O www/scripts/fgEmojiPicker.js https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/fgEmojiPicker.js
 	wget -O www/scripts/full-emoji-list.json https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/full-emoji-list.json
 	wget -O www/scripts/full-emoji-list.json https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/full-emoji-list.json

+ 3 - 1
Readme.md

@@ -13,7 +13,9 @@ Deployment is currently:
 A Dockerfile and deployment scripts are provided for your convenience in building/running containers based on this:
 A Dockerfile and deployment scripts are provided for your convenience in building/running containers based on this:
 ```
 ```
 # Build and run the server
 # Build and run the server
-./docker-deploy.sh
+./fulldeploy.sh
+# Just run the server with latest changes
+./dockerdeploy.sh
 # Extract configuration & local data, then spin down the server
 # Extract configuration & local data, then spin down the server
 ./docker-exfil.sh
 ./docker-exfil.sh
 ```
 ```

+ 2 - 2
dockerdeploy.sh

@@ -1,3 +1,3 @@
 #!/bin/sh
 #!/bin/sh
-sudo docker build -t troglodyne/tcms .
-sudo docker run -dp 5000:5000 troglodyne/tcms:latest /usr/bin/starman -p 5000 www/server.psgi
+docker build -t troglodyne/tcms .
+docker run -dp 5000:5000 troglodyne/tcms:latest "//usr/bin/starman" "www/server.psgi"

+ 3 - 0
fulldeploy.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+docker build -t troglodyne/base . -f Dockerfile.build
+./dockerdeploy.sh

+ 3 - 2
lib/Trog/Routes/HTML.pm

@@ -6,6 +6,7 @@ use warnings;
 no warnings 'experimental';
 no warnings 'experimental';
 use feature qw{signatures state};
 use feature qw{signatures state};
 
 
+use Errno qw{ENOENT};
 use File::Touch();
 use File::Touch();
 use List::Util();
 use List::Util();
 use Capture::Tiny qw{capture};
 use Capture::Tiny qw{capture};
@@ -431,7 +432,7 @@ sub config ($query, $render_cb) {
         theme_dir          => $td,
         theme_dir          => $td,
         stylesheets        => $css,
         stylesheets        => $css,
         scripts            => $js,
         scripts            => $js,
-        themes             => _get_themes(),
+        themes             => _get_themes() || [],
         data_models        => _get_data_models(),
         data_models        => _get_data_models(),
         current_theme      => $conf->param('general.theme') // '',
         current_theme      => $conf->param('general.theme') // '',
         current_data_model => $conf->param('general.data_model') // 'DUMMY',
         current_data_model => $conf->param('general.data_model') // 'DUMMY',
@@ -443,7 +444,7 @@ sub config ($query, $render_cb) {
 
 
 sub _get_themes {
 sub _get_themes {
     my $dir = 'www/themes';
     my $dir = 'www/themes';
-    opendir(my $dh, $dir) || die "Can't opendir $dir: $!";
+    opendir(my $dh, $dir) || do { die "Can't opendir $dir: $!" unless $!{ENOENT} };
     my @tdirs = grep { !/^\./ && -d "$dir/$_" } readdir($dh);
     my @tdirs = grep { !/^\./ && -d "$dir/$_" } readdir($dh);
     closedir $dh;
     closedir $dh;
     return \@tdirs;
     return \@tdirs;

+ 9 - 0
service-files/systemd.unit

@@ -0,0 +1,9 @@
+[Unit]
+Description=tCMS
+
+[Install]
+WantedBy=default.target
+
+[Service]
+ExecStart=starman __REPLACEME__/www/server.psgi
+WorkingDirectory= __REPLACEME__/