Browse Source

Merge pull request #152 from EvanCarroll/master

ENTERPRISE QUALITY PULL REQUEST
George S. Baugh 5 năm trước cách đây
mục cha
commit
a0f7fa30ac
4 tập tin đã thay đổi với 121 bổ sung15 xóa
  1. 19 15
      CHANGELOG
  2. 47 0
      Makefile.PL
  3. 17 0
      images/README.md
  4. 38 0
      images/base.sh

+ 19 - 15
CHANGELOG

@@ -1,9 +1,11 @@
+# I Would highly suggest removing this. And either including it in the repo,
+# Or, having the app bootstrap it.
 .PHONY: install
 install:
 	test -d $(HOME)/.tcms || mkdir $(HOME)/.tcms
 	test -d www/themes || mkdir www/themes
 	test -d data/files || mkdir data/files
-	rm pod2htmd.tmp; /bin/true
+	$(RM) pod2htmd.tmp;
 
 .PHONY: install-service
 install-service:
@@ -15,21 +17,23 @@ install-service:
 	systemctl --user start tCMS
 	loginctl enable-linger $(USER)
 
-.PHONY: test
-test: reset-dummy-data
-	prove
-
 .PHONY: reset-dummy-data
 reset-dummy-data:
 	cp -f data/DUMMY-dist.json data/DUMMY.json
 
-.PHONY: depend
-depend:
-	apt-get install -y sqlite3 libsqlite3-dev libdbd-sqlite3-perl cpanminus starman libxml2 wget
-	apt-get install -y libtext-xslate-perl libplack-perl libconfig-tiny-perl libdatetime-format-http-perl libjson-maybexs-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 libmoose-perl libmoosex-types-datetime-perl libxml-libxml-perl
-	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/full-emoji-list.json https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/full-emoji-list.json
+.PHONY: prereq-debian
+prereq-debian: prereq-frontend prereq-perl
+	apt-get install -y sqlite3 libsqlite3-dev libdbd-sqlite3-perl cpanminus starman libxml2 wget                         \
+	    libtext-xslate-perl libplack-perl libconfig-tiny-perl libdatetime-format-http-perl libjson-maybexs-perl          \
+	    libuuid-tiny-perl libcapture-tiny-perl libconfig-simple-perl libdbi-perl libfile-slurper-perl libfile-touch-perl \
+	    libfile-copy-recursive-perl libxml-rss-perl libmodule-install-perl                                               \
+	    libmoose-perl libmoosex-types-datetime-perl libxml-libxml-perl
+
+.PHONY: prereq-perl
+	cpanm -n --installdeps .
+
+.PHONY: prereq-frontend
+prereq-frontend:
+	mkdir -p www/scripts; cd www/scripts && curl --remote-name-all                                  \
+		"https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/fgEmojiPicker.js"     \
+	  "https://github.com/woody180/vanilla-javascript-emoji-picker/raw/master/full-emoji-list.json"

+ 47 - 0
Makefile.PL

@@ -0,0 +1,47 @@
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+  VERSION   => '0.01',
+  META_MERGE        => {
+    "meta-spec" => { version => 2 },
+    resources => {
+      repository => {
+          type => 'git',
+          url  => 'git@github.com:Troglodyne-Internet-Widgets/tCMS.git',
+          web  => 'https://github.com/Troglodyne-Internet-Widgets/tCMS',
+      },
+    },
+  },
+  PREREQ_PM => {
+    'CGI::Cookie'            => '0',
+    'Capture::Tiny'          => '0',
+    'Carp'                   => '0',
+    'Config::Simple'         => '0',
+    'DBD::SQLite'            => '0',
+    'DBI'                    => '0',
+    'Date::Format'           => '0',
+    'DateTime::Format::HTTP' => '0',
+    'Digest::SHA'            => '0',
+    'Errno'                  => '0',
+    'File::Basename'         => '0',
+    'File::Copy'             => '0',
+    'File::Slurper'          => '0',
+    'File::Touch'            => '0',
+    'HTTP::Body'             => '0',
+    'JSON::MaybeXS'          => '0',
+    'List::Util'             => '0',
+    'Mojo::File'             => '0',
+    'POSIX'                  => '0',
+    'Pod::Html'              => '0',
+    'Starman'                => '0',
+    'Text::Xslate'           => '0',
+    'URL::Encode'            => '0',
+    'UUID::Tiny'             => '0',
+    'WWW::Sitemap::XML'      => '0',
+    'WWW::SitemapIndex::XML' => '0',
+  },
+  test => {TESTS => 't/*.t'}
+);

+ 17 - 0
images/README.md

@@ -0,0 +1,17 @@
+Containerization
+====
+
+Root is not required to build or run the image.
+
+
+Images can be built like this,
+
+```
+$ buildah unshare ./images/base.sh
+```
+
+Containers can be run like this,
+
+```
+$ podman run -p 0.0.0.0:5000:5000 localhost/tcms
+```

+ 38 - 0
images/base.sh

@@ -0,0 +1,38 @@
+#!/bin/sh
+
+ctr=$(buildah from alpine:latest)
+mnt=$(buildah mount "$ctr")
+
+mkdir -p "$mnt/srv/tcms" "$mnt/tmp/tcms"
+cp -R bin/ config/ data/ www/ lib "$mnt/srv/tcms";
+cp Makefile.PL "$mnt/tmp/tcms/"
+make -C "$mnt/srv/tcms" --makefile "$PWD/Makefile" prereq-frontend reset-dummy-data
+
+buildah run -- $ctr sh <<EOF
+  apk update
+  apk add perl perl-xml-libxml perl-moose perl-datetime perl-dbi perl-dbd-sqlite perl-capture-tiny perl-date-format
+
+	# needed for install
+	apk add curl make musl-dev perl-dev gcc mlocate perl-app-cpanminus
+	cpanm -n --no-wget --curl --installdeps /tmp/tcms/
+	apk del curl make musl-dev perl-dev gcc mlocate perl-app-cpanminus
+EOF
+
+rm -rf \
+	"$mnt/tmp/tcms"       \
+	"$mnt/var/cache/*"    \
+	"$mnt/root/.cpanm"    \
+	"$mnt/usr/share/man/" \
+  "$mnt/usr/local/share/man"
+
+find "$mnt/usr/lib/perl5" -name '*.pod' -delete
+
+buildah config                              \
+  --workingdir "/srv/tcms/"                 \
+	--entrypoint '["/usr/local/bin/starman"]' \
+	--cmd "/srv/tcms/www/server.psgi"         \
+	--port 5000                               \
+	--label "Name=tCMS"                       \
+	--author "George Baugh"                   \
+	"$ctr"
+buildah commit --rm "$ctr" tcms