Browse Source

working on stuff

feature/startup-from-labels
root 5 years ago
parent
commit
b6ec6d7953
  1. 62
      bin/build
  2. 13
      bin/launch
  3. 0
      install.sh
  4. 7
      nextcloud/build.sh
  5. 0
      src/debian/Containerfile
  6. 0
      src/debian/build.sh
  7. 30
      src/nextcloud/Containerfile
  8. 17
      src/nextcloud/Systemdfile
  9. 0
      src/nextcloud/resources/apache/nextcloud.conf
  10. 0
      src/nextcloud/resources/bin/db-dump
  11. 0
      src/nextcloud/resources/bin/db-redo
  12. 0
      src/nextcloud/resources/bin/nc-occ
  13. 2
      src/nextcloud/resources/crontab
  14. 2
      src/nextcloud/resources/my.config.php
  15. 0
      src/nextcloud/resources/php/php.ini
  16. 0
      src/nextcloud/resources/php/www.conf
  17. 0
      src/nextcloud/resources/postgresql/pg_hba.conf
  18. 0
      src/nextcloud/resources/postgresql/redo.sql
  19. 0
      src/nextcloud/resources/redis.conf

62
bin/build

@ -0,0 +1,62 @@
#!/bin/bash
# potential flags: custom tag, no squash, delete/redo, custom dir
# Parameters
if [[ $# -eq 0 ]]; then
echo "Usage: $0 imagedir [containername]"
exit 0
fi
if [[ ! -d $1 ]]; then
echo "Error: directory \"$1\" not found."
exit 1
else
proj=$1
fi
if [[ -n $2 ]]; then
cont=$2
else
cont=$proj
fi
fail() {
podman image rm $proj:$today
podman rm -f $cont
echo "Encountered unexpected error. Exiting."
exit 2
}
today=$(date "+%Y-%m-%d-T%H%M")
tag=latest
# Main
set -e
cd $proj
# execute install script if it exists
# install script should be idempotent
if [[ -f Install ]]; then
./Install
fi
# build image
echo "Building container ..."
podman build -f Containerfile -t $proj:$today -t $proj:$tag || fail
#--squash
# start container
echo "Creating container ..."
podman create --name $cont $proj:$today || fail
podman start $cont || fail
# Systemdfile is for commands that need systemd to execute
echo "Running build steps that require systemd ..."
podman exec $cont bash -c "if [ -f /root/Systemdfile ]; then /root/Systemdfile; fi" || fail
echo "Finished!"
# get container IP
printf "Container IP is: "
podman inspect -f '{{ .NetworkSettings.IPAddress }}' $cont
#echo "Use this address to configure your reverse proxy"
# todo: configure autostart service
# todo: handle volumes

13
bin/launch

@ -0,0 +1,13 @@
#!/bin/bash
if [[ -z $1 ]]; then
echo "Usage: $0 image [name]"
exit 1
fi
if [[ -z $2 ]]; then
2=$1
fi
podman create --name $2 $1
podman start $2

0
install.sh

7
nextcloud/build.sh

@ -1,7 +0,0 @@
#!/bin/bash
# Variables
today=$(date "+%Y-%m-%d-T%H%M")
proj=nextcloud
podman build -f Containerfile -t $proj:$today -t $proj:latest #--squash

0
debian/Containerfile → src/debian/Containerfile

0
debian/build.sh → src/debian/build.sh

30
nextcloud/Containerfile → src/nextcloud/Containerfile

@ -1,7 +1,6 @@
### Meta ### ### Meta ###
FROM localhost/debian FROM localhost/debian
# Versions of various packages that we may need to refer to
ARG phpv=7.3 ARG phpv=7.3
ARG psqlv=11 ARG psqlv=11
@ -10,27 +9,27 @@ EXPOSE 80/tcp
### Basics ### ### Basics ###
RUN apt update -y && apt install -y systemd sudo wget apache2 php-fpm \ RUN apt update -y && apt install -y systemd sudo wget apache2 php-fpm \
php-gd php-zip php-pgsql php-curl php-mbstring php-intl php-imagick \ php-gd php-zip php-pgsql php-curl php-mbstring php-intl php-imagick \
php-xml php-json redis-server php-redis postgresql postgresql-doc unzip php-xml php-json redis-server php-redis postgresql postgresql-doc \
unzip php-ldap
RUN mkdir -p /srv/nextcloud/database /srv/nextcloud/files && chown -R www-data:www-data \ RUN mkdir -p /srv/nextcloud/database /srv/nextcloud/files && chown -R www-data:www-data /srv/nextcloud
/srv/nextcloud
COPY resources/bin/ /usr/local/bin/ COPY resources/bin/ /usr/local/bin/
### Apache ### ### Apache ###
RUN a2enmod rewrite headers env dir mime proxy_fcgi && a2enconf php${phpv}-fpm RUN a2enmod rewrite headers env dir mime proxy_fcgi && a2enconf php${phpv}-fpm
COPY resources/site.conf /etc/apache2/sites-available/ COPY resources/apache/nextcloud.conf /etc/apache2/sites-available/
WORKDIR /etc/apache2/sites-enabled WORKDIR /etc/apache2/sites-enabled
RUN rm 000-default.conf && ln -s ../sites-available/site.conf RUN rm 000-default.conf && ln -s ../sites-available/nextcloud.conf
### PHP ### ### PHP ###
RUN systemctl enable php${phpv}-fpm RUN systemctl enable php${phpv}-fpm
COPY resources/php.ini /etc/php/${phpv}/fpm/ COPY resources/php/php.ini /etc/php/${phpv}/fpm/
COPY config/php/www.conf /etc/php/${phpv}/fpm/pool.d/ COPY resources/php/www.conf /etc/php/${phpv}/fpm/pool.d/
### Redis ### ### Redis ###
COPY --chown=redis:redis resources/redis.conf /etc/redis/ COPY --chown=redis:redis resources/redis.conf /etc/redis/
@ -38,11 +37,9 @@ COPY --chown=redis:redis resources/redis.conf /etc/redis/
RUN usermod -a -G redis www-data RUN usermod -a -G redis www-data
### PostgreSQL ### ### PostgreSQL ###
COPY --chown=postgres:postgres resources/pg_hba.conf /etc/postgresql/${psqlv}/main/pg_hba.conf COPY --chown=postgres:postgres resources/postgresql/pg_hba.conf /etc/postgresql/${psqlv}/main/pg_hba.conf
COPY --chown=postgres:postgres resources/redo.sql /usr/local/lib/psql/ COPY --chown=postgres:postgres resources/postgresql/redo.sql /usr/local/lib/psql/
#RUN db-redo
### Nextcloud ### ### Nextcloud ###
WORKDIR /var/www/html WORKDIR /var/www/html
@ -52,11 +49,7 @@ RUN wget https://download.nextcloud.com/server/releases/latest.zip && \
chown -R www-data:www-data nextcloud && \ chown -R www-data:www-data nextcloud && \
rm latest.zip rm latest.zip
COPY --chown=www-data:www-data config/nextcloud/my.config.php nextcloud/config/ COPY --chown=www-data:www-data resources/my.config.php nextcloud/config/
#RUN nc-occ maintenance:install --data-dir "/srv/nextcloud/files/" --database "pgsql" --database-host "/var/run/postgresql" --database-name "nextcloud" --database-user "ncadmin" --database-pass "" --admin-user "admin" --admin-pass "admin"
#RUN nc-occ maintenance:update:htaccess && nc-occ db:add-missing-indices && nc-occ db:convert-filecache-bigint
# TODO: install apps via occ # TODO: install apps via occ
@ -65,3 +58,6 @@ WORKDIR /root
COPY resources/crontab . COPY resources/crontab .
RUN crontab -u www-data crontab && rm crontab RUN crontab -u www-data crontab && rm crontab
### Systemdfile ###
COPY Systemdfile /root/
RUN chmod +x /root/Systemdfile

17
src/nextcloud/Systemdfile

@ -0,0 +1,17 @@
#!/bin/bash
# fail if any command returns error
set -e
# wait 5 seconds to make sure all services have finished starting up
sleep 5
# make database for nextcloud
db-redo
# install nextcloud
nc-occ maintenance:install --data-dir "/srv/nextcloud/files/" --database "pgsql" --database-host "/var/run/postgresql" --database-name "nextcloud" --database-user "ncadmin" --database-pass "" --admin-user "admin" --admin-pass "admin"
# configure nextcloud options
nc-occ maintenance:update:htaccess
nc-occ db:add-missing-indices
nc-occ db:convert-filecache-bigint

0
nextcloud/resources/site.conf → src/nextcloud/resources/apache/nextcloud.conf

0
nextcloud/resources/bin/db-dump → src/nextcloud/resources/bin/db-dump

0
nextcloud/resources/bin/db-redo → src/nextcloud/resources/bin/db-redo

0
nextcloud/resources/bin/nc-occ → src/nextcloud/resources/bin/nc-occ

2
nextcloud/resources/crontab → src/nextcloud/resources/crontab

@ -2,6 +2,6 @@
# Run Nextcloud cron tasks every 5 minutes # Run Nextcloud cron tasks every 5 minutes
*/5 * * * * php -f /var/www/html/nextcloud/cron.php */5 * * * * php -f /var/www/html/nextcloud/cron.php
# Dump database every hour # Dump database every hour
10 * * * * /usr/local/bin/dbdump 01 10 * * * * /usr/local/bin/db-dump 01
# Scan for new files every 15 minutes # Scan for new files every 15 minutes
*/15 * * * * nc-occ files:scan --all */15 * * * * nc-occ files:scan --all

2
nextcloud/config/nextcloud/my.config.php → src/nextcloud/resources/my.config.php

@ -24,6 +24,7 @@ $CONFIG = array(
'overwrite.cli.url' => 'http://medusa.casa.alemor.org/nextcloud/', 'overwrite.cli.url' => 'http://medusa.casa.alemor.org/nextcloud/',
/** Memory Caching **/ /** Memory Caching **/
/**
'memcache.local' => '\\OC\\Memcache\\Redis', 'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis', 'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis', 'memcache.locking' => '\\OC\\Memcache\\Redis',
@ -34,5 +35,6 @@ $CONFIG = array(
'port' => 0, 'port' => 0,
'timeout' => 0.0, 'timeout' => 0.0,
), ),
**/
); );

0
nextcloud/resources/php.ini → src/nextcloud/resources/php/php.ini

0
nextcloud/config/php/www.conf → src/nextcloud/resources/php/www.conf

0
nextcloud/resources/pg_hba.conf → src/nextcloud/resources/postgresql/pg_hba.conf

0
nextcloud/resources/redo.sql → src/nextcloud/resources/postgresql/redo.sql

0
nextcloud/resources/redis.conf → src/nextcloud/resources/redis.conf

Loading…
Cancel
Save