parent
4262468d97
commit
7408975222
6 changed files with 149 additions and 41 deletions
4
.hadolint.yaml
Normal file
4
.hadolint.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
ignored:
|
||||
- DL3003
|
||||
- DL3008
|
51
Dockerfile
51
Dockerfile
|
@ -1,5 +1,18 @@
|
|||
FROM golang:1.16.0-buster as supercronic
|
||||
|
||||
# renovate: datasource=github-tags depName=aptible/supercronic versioning=semver
|
||||
ENV SUPERCRONIC_VERSION v0.1.12
|
||||
|
||||
RUN set -ex; \
|
||||
git clone --branch $SUPERCRONIC_VERSION https://github.com/aptible/supercronic; \
|
||||
cd supercronic; \
|
||||
go mod vendor; \
|
||||
go install;
|
||||
|
||||
FROM debian:10.8-slim@sha256:13f0764262a064b2dd9f8a828bbaab29bdb1a1a0ac6adc8610a0a5f37e514955 AS prep
|
||||
|
||||
ENV FLOX_VERSION master
|
||||
|
||||
RUN set -ex; \
|
||||
\
|
||||
apt-get update; \
|
||||
|
@ -10,14 +23,19 @@ RUN set -ex; \
|
|||
git clone --branch $FLOX_VERSION https://github.com/devfake/flox.git /flox;
|
||||
|
||||
FROM composer:1.10.19@sha256:594befc8126f09039ad17fcbbd2e4e353b1156aba20556a6c474a8ed07ed7a5a AS composer
|
||||
|
||||
COPY --from=prep /flox /flox
|
||||
|
||||
RUN set -ex; \
|
||||
\
|
||||
cd /flox/backend; \
|
||||
composer install;
|
||||
|
||||
FROM php:7.4.15-fpm-buster@sha256:a835cfb03b611962d8d8c78c92b3ed49eb640708ea119ce3f1195483e91ef927
|
||||
|
||||
COPY --from=composer /flox /usr/share/flox
|
||||
COPY --from=supercronic /go/bin/supercronic /usr/local/bin/supercronic
|
||||
|
||||
RUN set -ex; \
|
||||
\
|
||||
groupadd --system foo; \
|
||||
|
@ -26,55 +44,32 @@ RUN set -ex; \
|
|||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
supervisor \
|
||||
busybox-static \
|
||||
gosu \
|
||||
sqlite3 \
|
||||
rsync \
|
||||
libpq5 \
|
||||
libpq-dev \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
chmod +x /usr/local/bin/supercronic; \
|
||||
echo '* * * * * php /var/www/flox/backend/artisan schedule:run >> /dev/null 2>&1' > /crontab; \
|
||||
\
|
||||
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
|
||||
\
|
||||
mkdir -p \
|
||||
/var/log/supervisord \
|
||||
/var/run/supervisord \
|
||||
/var/spool/cron/crontabs \
|
||||
/var/www/flox \
|
||||
; \
|
||||
echo '* * * * * php /var/www/flox/backend/artisan schedule:run >> /dev/null 2>&1' > /var/spool/cron/crontabs/foo;
|
||||
|
||||
RUN set -ex; \
|
||||
\
|
||||
savedAptMark="$(apt-mark showmanual)"; \
|
||||
\
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libpq-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bcmath \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
opcache \
|
||||
; \
|
||||
\
|
||||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
|
||||
| awk '/=>/ { print $3 }' \
|
||||
| sort -u \
|
||||
| xargs -r dpkg-query -S \
|
||||
| cut -d: -f1 \
|
||||
| sort -u \
|
||||
| xargs -rt apt-mark manual; \
|
||||
\
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
|
||||
apt-get purge -y --autoremove libpq-dev; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY cron.sh /cron.sh
|
||||
COPY supervisord.conf /supervisord.conf
|
||||
|
||||
WORKDIR /var/www/flox
|
||||
|
|
116
README.md
116
README.md
|
@ -1,5 +1,119 @@
|
|||
# docker-flox
|
||||
|
||||
[](https://build.walbeck.it/mwalbeck/docker-flox)
|
||||

|
||||
|
||||
This is a docker image for [flox](https://github.com/devfake/flox) built from the current master branch.
|
||||
This is a docker image for [flox](https://github.com/devfake/flox) built from the current master branch. You can find the image on [Docker Hub](https://hub.docker.com/r/mwalbeck/flox) and the source code can be found [here](https://git.walbeck.it/mwalbeck/docker-flox) with a mirror on [github](https://github/mwalbeck/docker-flox).
|
||||
|
||||
## Usage
|
||||
|
||||
This is a php-fpm based image, which means you need another container to act as the webserver. For this I would recommend nginx and you can find an example nginx config below.
|
||||
|
||||
The container can be configured with environment variables and you can see the list of options below. You can also specify an arbitrary UID and GID for the container to run as with the default being 1000 for both.
|
||||
|
||||
The container support using Mariadb/MySQL or PostreSQL as the database instead of sqlite, and is the reason why the image is currently being built from master instead of the latest release.
|
||||
|
||||
OBS: The very first time you start the container ```FLOX_DB_INIT``` should be set to true. Afterwards it should be set to false and the container should be restarted. ```FLOX_DB_INIT``` should only be set when you want to initialise a new database. If you don't set it to false after the first run then the container will failed to start.
|
||||
|
||||
## Config options
|
||||
|
||||
|Variable name |default value|description|
|
||||
|--------------------------|-------------|-----------|
|
||||
|UID |1000|The user id the container should run as.|
|
||||
|GID |1000|The group id the container should run as.|
|
||||
|FLOX_DB_INIT |false|If the database should be initialised when the container is started. Should only be true the first time you start the container.|
|
||||
|FLOX_DB_CONNECTION |sqlite|Which database type to use. Can be either ```sqlite```, ```mysql``` or ```pgsql```|
|
||||
|FLOX_DB_NAME |/var/www/flox/backend/database/database.sqlite|The name of the database or when using sqlite the filepath of the database file.|
|
||||
|FLOX_DB_USER |-|The database user. Only applicable when using either ```mysql``` or ```pgsql```|
|
||||
|FLOX_DB_PASS |-|The database users password. Only applicable when using either ```mysql``` or ```pgsql```|
|
||||
|FLOX_DB_HOST |localhost|IP address or hostname for the database. Only applicable when using either ```mysql``` or ```pgsql```|
|
||||
|FLOX_DB_PORT |3306|The port the database is listening on. Only applicable when using either ```mysql``` or ```pgsql```|
|
||||
|FLOX_ADMIN_USER |admin|Username of the admin account|
|
||||
|FLOX_ADMIN_PASS |admin|Password of the admin account|
|
||||
|FLOX_APP_URL |http://localhost|The root URL for flox|
|
||||
|FLOX_APP_ENV |local|The application environment. Can either be ```local``` or ```production```|
|
||||
|FLOX_APP_DEBUG |false|Debug mode. Can either be ```true``` or ```false```|
|
||||
|FLOX_CLIENT_URI |/||
|
||||
|FLOX_TIMEZONE |UTC|Your timezone. Look [here](https://www.php.net/manual/en/timezones.php) for timezone names|
|
||||
|FLOX_DAILY_REMINDER_TIME |10:00||
|
||||
|FLOX_WEEKLY_REMINDER_TIME |20:00||
|
||||
|TMDB_API_KEY |-|An API key for TMDB. Look [here](https://www.themoviedb.org/faq/api) for more info|
|
||||
|
||||
## Example docker-compose
|
||||
```
|
||||
version: '2'
|
||||
|
||||
volumes:
|
||||
flox:
|
||||
|
||||
networks:
|
||||
frontend:
|
||||
|
||||
services:
|
||||
flox:
|
||||
image: mwalbeck/getgrav:latest
|
||||
restart: on-failure:5
|
||||
networks:
|
||||
- frontend
|
||||
volumes:
|
||||
- flox:/var/www/flox
|
||||
environment:
|
||||
FLOX_ADMIN_USER: "something"
|
||||
FLOX_ADMIN_PASS: "something"
|
||||
FLOX_APP_URL: "something"
|
||||
TMDB_API_KEY: "something"
|
||||
FLOX_DB_INIT: true
|
||||
|
||||
web:
|
||||
image: nginx:latest
|
||||
restart: on-failure:5
|
||||
networks:
|
||||
- frontend
|
||||
volumes:
|
||||
- flox:/var/www/flox:ro
|
||||
- /path/to/nginx:/etc/nginx:ro
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
```
|
||||
|
||||
## Example nginx config
|
||||
```
|
||||
server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /var/www/flox/public;
|
||||
|
||||
index index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
location ~ /\. {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
deny all;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
error_page 404 /index.php;
|
||||
|
||||
location = /index.php {
|
||||
fastcgi_pass flox:9000;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
try_files $fastcgi_script_name =404;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
|
||||
location ~ \.php$ { return 403; }
|
||||
}
|
||||
```
|
||||
|
|
4
cron.sh
4
cron.sh
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
exec busybox crond -f -l 0 -L /dev/stdout
|
|
@ -36,10 +36,10 @@ rsync -rlD --delete \
|
|||
cd backend
|
||||
|
||||
if [ "$FLOX_DB_CONNECTION" = "sqlite" ]; then
|
||||
touch /var/www/flox/backend/database/database.sqlite
|
||||
php artisan flox:init --no-interaction $FLOX_DB_NAME
|
||||
touch "$FLOX_DB_NAME"
|
||||
php artisan flox:init --no-interaction "$FLOX_DB_NAME"
|
||||
else
|
||||
php artisan flox:init --no-interaction $FLOX_DB_NAME $FLOX_DB_USER $FLOX_DB_PASS $FLOX_DB_HOST $FLOX_DB_PORT
|
||||
php artisan flox:init --no-interaction "$FLOX_DB_NAME" "$FLOX_DB_USER" "$FLOX_DB_PASS" "$FLOX_DB_HOST" "$FLOX_DB_PORT"
|
||||
fi
|
||||
|
||||
sed -i "s!^DB_CONNECTION=.*!DB_CONNECTION=$FLOX_DB_CONNECTION!g" .env
|
||||
|
@ -50,10 +50,10 @@ sed -i "s!^APP_DEBUG=.*!APP_DEBUG=$FLOX_APP_DEBUG!g" .env
|
|||
sed -i "s!^TIMEZONE=.*!TIMEZONE=$FLOX_TIMEZONE!g" .env
|
||||
sed -i "s!^DAILY_REMINDER_TIME=.*!DAILY_REMINDER_TIME=$FLOX_DAILY_REMINDER_TIME!g" .env
|
||||
sed -i "s!^WEEKLY_REMINDER_TIME=.*!WEEKLY_REMINDER_TIME=$FLOX_WEEKLY_REMINDER_TIME!g" .env
|
||||
sed -i "s!^APP_ENV=.*!APP_ENV=local!g" .env
|
||||
sed -i "s!^APP_ENV=.*!APP_ENV=$FLOX_APP_ENV!g" .env
|
||||
|
||||
if [ "$FLOX_DB_INIT" = "true" ]; then
|
||||
php artisan flox:db --no-interaction $FLOX_ADMIN_USER $FLOX_ADMIN_PASS
|
||||
php artisan flox:db --no-interaction "$FLOX_ADMIN_USER" "$FLOX_ADMIN_PASS"
|
||||
else
|
||||
php artisan migrate
|
||||
fi
|
||||
|
@ -63,7 +63,6 @@ sed -i "s!^APP_ENV=.*!APP_ENV=$FLOX_APP_ENV!g" .env
|
|||
chown foo /proc/self/fd/1 /proc/self/fd/2
|
||||
chown -R foo:foo /var/www/flox \
|
||||
/var/log/supervisord \
|
||||
/var/run/supervisord \
|
||||
/var/spool/cron/crontabs
|
||||
/var/run/supervisord
|
||||
|
||||
exec gosu foo "$@"
|
||||
|
|
|
@ -26,4 +26,4 @@ stdout_logfile=/dev/stdout
|
|||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
command=/cron.sh
|
||||
command=supercronic /crontab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue