Commit b65f3729 authored by Arnaud de Mouhy's avatar Arnaud de Mouhy
Browse files

Dockerized

parent 4a37e722
.ash_history
.git
.cpan
.cpanm
/files/
/local/
/lutim.conf
/lutim.db
\ No newline at end of file
......@@ -18,3 +18,7 @@ tmp/*
.zanata-cache/*
cover_db/*
*.passwd
.ash_history
.vscode/
.DS_Store
.cpanm/
\ No newline at end of file
FROM alpine:3.9
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Let's Upload That Image" \
org.label-schema.url="https://lut.im/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://git.framasoft.org/luc/lutim" \
org.label-schema.vendor="Luc Didry" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
RUN adduser -D lutim
COPY --chown=lutim:lutim . /home/lutim
WORKDIR /home/lutim
RUN /bin/sh /home/lutim/docker/build.sh
USER lutim
ENTRYPOINT ["/bin/sh", "/home/lutim/docker/entrypoint.sh"]
\ No newline at end of file
version: '3.3'
services:
app_dev:
build: .
ports:
- 8080:8080
volumes:
- .:/home/lutim
command: dev
postgres_dev:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: lutim
POSTGRES_DB: lutim
memcached:
image: memcached:1.5-alpine
adminer:
image: dehy/adminer
ports:
- 8081:80
\ No newline at end of file
version: '3.3'
services:
app:
build: .
ports:
- 8080:8080
volumes:
- ./lutim.conf:/home/lutim/lutim.conf:ro
db:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: lutim
POSTGRES_DB: lutim
cache:
image: memcached:1.5-alpine
minion:
build: .
command: minion
volumes:
- ./lutim.conf:/home/lutim/lutim.conf:ro
minion_db:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: lutim_minion
POSTGRES_DB: lutim_minion
\ No newline at end of file
version: '3.3'
services:
app:
image: aquinum/lutim
configs:
- source: lutim.conf
target: /home/lutim/lutim.conf
uid: '1000'
gid: '1000'
mode: 0440
deploy:
replicas: 1
db:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: <changeme>
POSTGRES_USER: lutim
POSTGRES_DB: lutim
cache:
image: memcached:1.5-alpine
minion:
image: aquinum/lutim
command: minion
configs:
- source: lutim.conf
target: /home/lutim/lutim.conf
uid: '1000'
gid: '1000'
mode: 0440
minion_db:
image: mariadb:10.3
environment:
MYSQL_ROOT_PASSWORD: <changeme>
MYSQL_DATABASE: lutim_minion
configs:
lutim.conf:
file: ./lutim.conf
\ No newline at end of file
#!/usr/bin/env sh
set -eu
apk update
apk add perl libpq perl-crypt-rijndael perl-io-socket-ssl perl-net-ssleay su-exec shared-mime-info libressl
sh $(dirname $0)/install-dev-env.sh
sh $(dirname $0)/install-imagemagick.sh
cpan notest Carton Config::FromHash
carton install --without test
# Remove dev env
apk del .build-deps
rm -rf /var/cache/apk/* /root/.cpan*
\ No newline at end of file
#!/bin/sh
set -eu
cd ~lutim
if [ "${1:-}" == "dev" ]
then
echo ""
echo ""
echo "Container started in dev mode. Connect to the container with the following command:"
echo " docker-compose -f docker-compose.dev.yml exec -u root app_dev sh"
echo ""
echo ""
echo "You can then install the build dependencies with this command"
echo " sh ~lutim/docker/install-dev-env.sh"
tail -f /dev/null
exit 0
fi
# If MySQL/PostgreSQL, wait for database to be up
DB_TYPE=$(perl utilities/read_conf.pl dbtype sqlite)
DB_HOST=
DB_PORT=
if [ "$DB_TYPE" == "postgresql" ]
then
DB_HOST=$(perl utilities/read_conf.pl pgdb/host db)
DB_PORT=$(perl utilities/read_conf.pl pgdb/port 5432)
fi
if [ -n "$DB_HOST" -a -n "$DB_PORT" ]
then
while ! nc -vz "${DB_HOST}" "${DB_PORT}"; do
echo "Waiting for database..."
sleep 1;
done
fi
if [ "${1:-}" == "minion" ]
then
exec carton exec script/application minion worker
fi
exec carton exec hypnotoad -f script/lutim
\ No newline at end of file
#!/usr/bin/env sh
apk --update add --virtual .build-deps build-base perl-utils perl-dev postgresql-dev vim wget zlib-dev
\ No newline at end of file
#!/usr/bin/env sh
# Instructions from https://imagemagick.org/script/perl-magick.php
set -eu
IM_VERSION=7.0.8-41
SHA256_DIGEST=93f73a245c25194f757c075df9f2ec40010376200cc664c21646565b8690112c
IM_DIR="ImageMagick-$IM_VERSION"
TARBALL="$IM_DIR.tar.gz"
ORIG_DIR="$(pwd)"
apk add libgomp libgcc libmagic \
libjpeg libjpeg-turbo-dev \
libpng libpng-dev \
tiff tiff-dev \
libwebp libwebp-dev
mkdir -p /tmp/im-build
cd /tmp/im-build
echo "$SHA256_DIGEST *$TARBALL" > SHA256SUM
wget https://imagemagick.org/download/$TARBALL -O $TARBALL
sha256sum -c SHA256SUM
tar xvf $TARBALL
cd $IM_DIR
./configure --with-perl --with-jpeg --with-png --with-tiff --with-webp
make -j$(nproc)
make install
ldconfig /usr/local/lib
perl -MImage::Magick -le 'print Image::Magick->QuantumDepth'
cd "$ORIG_DIR"
apk del libjpeg-turbo-dev libpng-dev tiff-dev libwebp-dev
rm -rf /tmp/im-build
\ No newline at end of file
#!/usr/bin/env perl
# read_conf.pl - Outputs lutim's config value for given keypath
use strict;
use warnings;
use FindBin;
use Cwd qw(realpath);
use Config::FromHash;
sub print_help {
print <<END;
Usage:
$0 [-h] KEYPATH [DEFAULT] -- reads the lutim.conf file and outputs value at KEYPATH, or prints DEFAULT value
where:
-h prints this help message and exit
KEYPATH refers to the path in the hash, slash-separated (ie. mysqldb/host)
DEFAULT if keypath is undefined, return this value (ie. localhost)
END
return;
}
if (defined $ARGV[0] and $ARGV[0] eq "-h") {
print_help();
exit 0;
}
if (not defined $ARGV[0]) {
print_help();
exit 1;
}
my $filename = realpath("$FindBin::Bin/../lutim.conf");
if (! -r $filename) {
print STDERR "Error: unable to read config file \"$filename\"\n";
exit 1;
}
my $config = Config::FromHash->new(filename => $filename);
my $value = $config->get($ARGV[0]);
if (defined $value) {
print $value;
exit 0;
}
if (not defined $value and defined $ARGV[1]) {
print $ARGV[1];
exit 0;
}
print STDERR "Error: keypath \"$ARGV[0]\" not found in config, and no default value provided.\n";
exit 1;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment