From a5d6d758d013009cd6cbbca5e9128a1d921ad8bd Mon Sep 17 00:00:00 2001 From: Akash Kakkar Date: Thu, 26 Dec 2019 16:26:18 +0530 Subject: [PATCH 1/9] squashed commits from @akash07k --- .dockerignore | 17 +++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++-- docker-compose.yml | 18 ++++++++++++++++ utils/docker/entrypoint.sh | 22 ++++++++++++++++++++ 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 utils/docker/entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0ed95f81a4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +.git +/assets/.cache +/data/favicons/*.png +/data/favicons/*.jpg +/data/thumbnails/*.png +/data/thumbnails/*.jpg +/data/cache/*.spc +/data/logs/*.log +/data/sqlite/*.db +/public +user.css +user.js +config.ini +node_modules +.env +vendor/ +.php_cs.cache diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..804439d961 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:bionic as source +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y && \ + rm -rf /var/lib/apt/lists/* + +COPY . selfoss/ + +FROM composer:1.9 as composer + +COPY --from=source /selfoss /selfoss + +RUN cd /selfoss && composer install --ignore-platform-reqs --optimize-autoloader --no-dev + + + +FROM node:13-buster as npm + +COPY --from=composer /selfoss /selfoss + +RUN cd /selfoss && npm install && npm install --prefix assets/ && npm run build + + + +FROM php:7.4-apache-buster + +COPY --from=npm /selfoss /var/www/html/ + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y libpng-dev \ + cron \ + && docker-php-ext-install -j$(nproc) gd \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /var/www/html/ + +RUN mkdir config && ln -s config/config.ini config.ini \ + && a2enmod rewrite + +VOLUME /var/www/html/data +VOLUME /var/www/html/config/ +RUN ls utils/docker + +ENTRYPOINT [ "bash" ] +CMD [ "utils/docker/entrypoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index 53a97b423b..b7cb20e732 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ For more information visit our [web site](https://selfoss.aditu.de). 1. Upload all files of this folder (IMPORTANT: also upload the invisible .htaccess files) 2. Make the directories data/cache, data/favicons, data/logs, data/thumbnails and data/sqlite writeable 3. Insert database access data in config.ini (see below -- you don't have to change anything if you want to use sqlite) -3. You don't have to install the database, it will be created automatically (ensure that your database has enought rights for creating triggers) -4. Create cronjob for updating feeds and point it to https://yourselfossurl.com/update via wget or curl. You can also execute the cliupdate.php from commandline. +4. You don't have to install the database, it will be created automatically (ensure that your database has enought rights for creating triggers) +5. Create cronjob for updating feeds and point it to https://yourselfossurl.com/update via wget or curl. You can also execute the cliupdate.php from commandline. If you obtained selfoss using Git, some more steps will be required. See the [development](#development) section. @@ -77,6 +77,25 @@ If you want to create a package with all the dependencies bundled, you can run ` Every patch is expected to adhere to our coding style, which is checked automatically by Travis. You can install the checkers locally using `npm run install-dependencies`, and then run the checks using `npm run check` before submitting a pull request. There is also `npm run fix`, that will attempt to fix the formatting. +## Dockerizing selfoss + +Dockerfile for Selfoss RSS aggregator is bundled in the repository. + +Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. + +To run the latest source use: +``` +docker-compose up +``` +Then find the web interface at http://localhost:8390 + +To rebuild the container with the latest code from source use: +``` +docker-compose -f docker-compose.yml build --no-cache +``` + +Thanks to @squatica for docker configuration. + ## Credits selfoss was created by [Tobias Zeising](tobias.zeising@aditu.de) and it is licensed under the GPLv3 license. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..74ab1788bb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" + +services: + app: + build: + context: . + dockerfile: ./Dockerfile + container_name: 'selfoss' + volumes: + - ./data:/var/www/html/data + - ./config:/var/www/html/config/ + restart: 'always' + ports: + - "8390:80" + +volumes: + data: + config: diff --git a/utils/docker/entrypoint.sh b/utils/docker/entrypoint.sh new file mode 100644 index 0000000000..ea644deedf --- /dev/null +++ b/utils/docker/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Make data directories owned by Apache +chown -R www-data:www-data \ + /var/www/html/data/cache \ + /var/www/html/data/favicons \ + /var/www/html/data/logs \ + /var/www/html/data/thumbnails \ + /var/www/html/data/sqlite + +# Create a config file when one does not exist +if [[ ! -f config/config.ini ]]; then + cp defaults.ini config/config.ini \ + && sed -i 's#^logger_destination=.*#logger_destination=file:php://stderr#' config/config.ini +fi + +# Run updater process periodically +su www-data -s /bin/bash -c 'php /var/www/html/cliupdate.php' >/dev/null 2>&1 +(while true; do su www-data -s /bin/bash -c 'php /var/www/html/cliupdate.php'; sleep 900; done;) & + +# Start the server and initiate the cron job +cron && apache2-foreground From f44a6ffdc0a3736e9788d7f30e0809bfe809826e Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Fri, 27 Dec 2019 16:27:37 +0100 Subject: [PATCH 2/9] had to upgrade deasync to 0.1.16 otherwise npm failed with "No module named ast" --- assets/package-lock.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/assets/package-lock.json b/assets/package-lock.json index 372ee5aecf..70a3c236ef 100644 --- a/assets/package-lock.json +++ b/assets/package-lock.json @@ -6012,8 +6012,7 @@ "node-addon-api": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz", - "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==", - "dev": true + "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==" }, "node-forge": { "version": "0.7.6", From 66a21a04262c050d5fda54496496cf2bcc8415ca Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Fri, 27 Dec 2019 16:36:47 +0100 Subject: [PATCH 3/9] "--dev" is obsolete --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfb550fad9..92ab47507a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "fix:server": "composer run-script fix", "install-dependencies": "npm run install-dependencies:client && npm run install-dependencies:server", "install-dependencies:client": "npm install --production=false --prefix assets/", - "install-dependencies:server": "composer install --dev", + "install-dependencies:server": "composer install", "lint:client": "npm run --prefix assets/ lint", "lint:server": "composer run-script lint", "test:server": "composer run-script test", From 987afc0345e910de47f3df15e8fb36265af1a0e4 Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Fri, 27 Dec 2019 16:32:00 +0100 Subject: [PATCH 4/9] dockerizing selfoss, fixes #1161 --- .dockerignore | 1 - .env.dist | 2 ++ Dockerfile | 42 ---------------------------------- README.md | 27 +++++++++++++++------- assets/package-lock.json | 3 ++- docker-compose.dev.yml | 16 +++++++++++++ docker-compose.yml | 11 ++++----- utils/docker/Dockerfile | 31 +++++++++++++++++++++++++ utils/docker/Dockerfile.dev | 28 +++++++++++++++++++++++ utils/docker/entrypoint.dev.sh | 6 +++++ utils/docker/entrypoint.sh | 4 ++-- 11 files changed, 111 insertions(+), 60 deletions(-) create mode 100644 .env.dist delete mode 100644 Dockerfile create mode 100644 docker-compose.dev.yml create mode 100644 utils/docker/Dockerfile create mode 100644 utils/docker/Dockerfile.dev create mode 100755 utils/docker/entrypoint.dev.sh mode change 100644 => 100755 utils/docker/entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 0ed95f81a4..8bb7f0dd9e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -.git /assets/.cache /data/favicons/*.png /data/favicons/*.jpg diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000000..32471050bc --- /dev/null +++ b/.env.dist @@ -0,0 +1,2 @@ +UID=1000 +GID=1000 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 804439d961..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -FROM ubuntu:bionic as source -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y && \ - rm -rf /var/lib/apt/lists/* - -COPY . selfoss/ - -FROM composer:1.9 as composer - -COPY --from=source /selfoss /selfoss - -RUN cd /selfoss && composer install --ignore-platform-reqs --optimize-autoloader --no-dev - - - -FROM node:13-buster as npm - -COPY --from=composer /selfoss /selfoss - -RUN cd /selfoss && npm install && npm install --prefix assets/ && npm run build - - - -FROM php:7.4-apache-buster - -COPY --from=npm /selfoss /var/www/html/ - -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y libpng-dev \ - cron \ - && docker-php-ext-install -j$(nproc) gd \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -WORKDIR /var/www/html/ - -RUN mkdir config && ln -s config/config.ini config.ini \ - && a2enmod rewrite - -VOLUME /var/www/html/data -VOLUME /var/www/html/config/ -RUN ls utils/docker - -ENTRYPOINT [ "bash" ] -CMD [ "utils/docker/entrypoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index b7cb20e732..37bb6f261b 100644 --- a/README.md +++ b/README.md @@ -79,22 +79,33 @@ Every patch is expected to adhere to our coding style, which is checked automati ## Dockerizing selfoss -Dockerfile for Selfoss RSS aggregator is bundled in the repository. +There are two Dockerfiles bundled in the repository - one for development, one for production deployment. -Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. +To build the production container use: +``` +docker-compose build --no-cache --pull +``` -To run the latest source use: +Then run it with: ``` docker-compose up ``` -Then find the web interface at http://localhost:8390 -To rebuild the container with the latest code from source use: +Selfoss web interface will be available at http://localhost:8390 + +Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. + +To run the development container first copy .env.dist into .env and make sure the UID and GID matches your own user and group ID, otherwise the dev scripts will create files with wrong access rights. ``` -docker-compose -f docker-compose.yml build --no-cache +cat .env.dist | sed 's/UID=1000/UID='$(id -u)'/' | sed 's/GID=1000/GID='$(id -g)'/' > .env ``` - -Thanks to @squatica for docker configuration. +Then build and run the dev container: +``` +docker-compose -f docker-compose.dev.yml build --no-cache --pull +docker-compose -f docker-compose.dev.yml run --rm -u node app npm run postinstall +docker-compose -f docker-compose.dev.yml up +``` +Dev Selfoss web interface will be available at http://localhost:8391, and you can run all the dev scripts like this: `docker-compose exec -u node npm run check` or simply jump into bash inside the container: `docker-compose exec -u node bash`. That's it, you can start developing! ## Credits diff --git a/assets/package-lock.json b/assets/package-lock.json index 70a3c236ef..372ee5aecf 100644 --- a/assets/package-lock.json +++ b/assets/package-lock.json @@ -6012,7 +6012,8 @@ "node-addon-api": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz", - "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==" + "integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==", + "dev": true }, "node-forge": { "version": "0.7.6", diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000000..c1bfea011b --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,16 @@ +version: "3" + +services: + # clean build with `docker-compose -f docker-compose.dev.yml build --no-cache --pull app` + app: + build: + args: + uid: ${UID} + gid: ${GID} + context: . + dockerfile: ./utils/docker/Dockerfile.dev + volumes: + - .:/var/www/html/ + restart: unless-stopped + ports: + - "8391:80" diff --git a/docker-compose.yml b/docker-compose.yml index 74ab1788bb..f028bf42ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,17 @@ version: "3" services: + # clean build with `docker-compose build --no-cache --pull app` app: + image: selfoss/selfoss build: context: . - dockerfile: ./Dockerfile - container_name: 'selfoss' + dockerfile: ./utils/docker/Dockerfile volumes: - - ./data:/var/www/html/data - - ./config:/var/www/html/config/ - restart: 'always' + - config:/var/www/html/config/ + restart: unless-stopped ports: - "8390:80" volumes: - data: config: diff --git a/utils/docker/Dockerfile b/utils/docker/Dockerfile new file mode 100644 index 0000000000..1a2b309d97 --- /dev/null +++ b/utils/docker/Dockerfile @@ -0,0 +1,31 @@ +FROM composer:1.9 as composer + +ADD . /selfoss + +RUN cd /selfoss && git reset HEAD && git checkout . && git clean -xdf && rm -fr .git \ + && composer install --ignore-platform-reqs --optimize-autoloader --no-dev + + + +FROM node:12-stretch as npm + +COPY --from=composer /selfoss /selfoss + +RUN cd /selfoss && npm i && npm install --prefix assets/ && npm run build + + + +FROM php:7.4-apache-buster + +COPY --from=npm /selfoss /var/www/html/ + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y libpng-dev \ + && docker-php-ext-install -j$(nproc) gd \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /var/www/html/ + +RUN mkdir config && ln -s config/config.ini config.ini \ + && a2enmod rewrite + +CMD [ "/var/www/html/utils/docker/entrypoint.sh" ] diff --git a/utils/docker/Dockerfile.dev b/utils/docker/Dockerfile.dev new file mode 100644 index 0000000000..67effc721f --- /dev/null +++ b/utils/docker/Dockerfile.dev @@ -0,0 +1,28 @@ +FROM php:7.4-apache-buster + +ARG gid +ARG uid + +RUN curl -sL https://deb.nodesource.com/setup_13.x | bash - \ + && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y libpng-dev nodejs gcc g++ make unzip \ + && docker-php-ext-install -j$(nproc) gd \ + && apt-get clean && rm -rf /var/lib/apt/lists/* \ + && a2enmod rewrite + +RUN curl -o /tmp/composer-setup.php "https://getcomposer.org/installer"; \ + EXPECTED_SIGNATURE="$(curl https://composer.github.io/installer.sig)"; \ + ACTUAL_SIGNATURE="$(sha384sum /tmp/composer-setup.php | cut -d ' ' -f 1)"; \ + if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then \ + >&2 echo 'ERROR: Invalid installer signature'; \ + rm /tmp/composer-setup.php && exit 1; \ + fi \ + && php /tmp/composer-setup.php --install-dir=/bin --filename=composer \ + && groupadd --gid ${gid} node \ + && useradd --uid ${uid} --gid node --shell /bin/bash --create-home node + +ENV APACHE_RUN_USER=node +ENV APACHE_RUN_GROUP=node + +VOLUME /var/www/html/ + +CMD [ "/var/www/html/utils/docker/entrypoint.dev.sh" ] diff --git a/utils/docker/entrypoint.dev.sh b/utils/docker/entrypoint.dev.sh new file mode 100755 index 0000000000..0b12eec01f --- /dev/null +++ b/utils/docker/entrypoint.dev.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Start the server and dev watcher +( + apache2-foreground & su node -c "npm run dev" +) diff --git a/utils/docker/entrypoint.sh b/utils/docker/entrypoint.sh old mode 100644 new mode 100755 index ea644deedf..2c7d558948 --- a/utils/docker/entrypoint.sh +++ b/utils/docker/entrypoint.sh @@ -18,5 +18,5 @@ fi su www-data -s /bin/bash -c 'php /var/www/html/cliupdate.php' >/dev/null 2>&1 (while true; do su www-data -s /bin/bash -c 'php /var/www/html/cliupdate.php'; sleep 900; done;) & -# Start the server and initiate the cron job -cron && apache2-foreground +# Start the server +apache2-foreground From ae802d260c0741be4b40b96a6ca1abc3c1611c86 Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Fri, 14 Feb 2020 18:40:11 +0100 Subject: [PATCH 5/9] simplified sed replacement --- utils/docker/entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/docker/entrypoint.sh b/utils/docker/entrypoint.sh index 2c7d558948..c757dc4320 100755 --- a/utils/docker/entrypoint.sh +++ b/utils/docker/entrypoint.sh @@ -10,8 +10,7 @@ chown -R www-data:www-data \ # Create a config file when one does not exist if [[ ! -f config/config.ini ]]; then - cp defaults.ini config/config.ini \ - && sed -i 's#^logger_destination=.*#logger_destination=file:php://stderr#' config/config.ini + sed 's#^logger_destination=.*#logger_destination=file:php://stderr#' defaults.ini > config/config.ini fi # Run updater process periodically From 8b334bba14f8c9b56d198e8d25f56eae21e4450b Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Sun, 16 Feb 2020 13:20:27 +0100 Subject: [PATCH 6/9] moved docker instructions into separate Readme --- README.md | 28 +--------------------------- utils/docker/Readme.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 utils/docker/Readme.md diff --git a/README.md b/README.md index 37bb6f261b..fde4c70a76 100644 --- a/README.md +++ b/README.md @@ -79,33 +79,7 @@ Every patch is expected to adhere to our coding style, which is checked automati ## Dockerizing selfoss -There are two Dockerfiles bundled in the repository - one for development, one for production deployment. - -To build the production container use: -``` -docker-compose build --no-cache --pull -``` - -Then run it with: -``` -docker-compose up -``` - -Selfoss web interface will be available at http://localhost:8390 - -Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. - -To run the development container first copy .env.dist into .env and make sure the UID and GID matches your own user and group ID, otherwise the dev scripts will create files with wrong access rights. -``` -cat .env.dist | sed 's/UID=1000/UID='$(id -u)'/' | sed 's/GID=1000/GID='$(id -g)'/' > .env -``` -Then build and run the dev container: -``` -docker-compose -f docker-compose.dev.yml build --no-cache --pull -docker-compose -f docker-compose.dev.yml run --rm -u node app npm run postinstall -docker-compose -f docker-compose.dev.yml up -``` -Dev Selfoss web interface will be available at http://localhost:8391, and you can run all the dev scripts like this: `docker-compose exec -u node npm run check` or simply jump into bash inside the container: `docker-compose exec -u node bash`. That's it, you can start developing! +For instructions how to use Selfoss inside docker container, both for production deployment and for development, see the separate [Readme](utils/docker/Readme.md). ## Credits diff --git a/utils/docker/Readme.md b/utils/docker/Readme.md new file mode 100644 index 0000000000..6a026ed545 --- /dev/null +++ b/utils/docker/Readme.md @@ -0,0 +1,29 @@ +## Dockerizing selfoss + +There are two Dockerfiles bundled in the repository - one for development, one for production deployment. + +To build the production container use: +``` +docker-compose build --no-cache --pull +``` + +Then run it with: +``` +docker-compose up +``` + +Selfoss web interface will be available at http://localhost:8390 + +Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. + +To run the development container first copy .env.dist into .env and make sure the UID and GID matches your own user and group ID, otherwise the dev scripts will create files with wrong access rights. +``` +cat .env.dist | sed 's/UID=1000/UID='$(id -u)'/' | sed 's/GID=1000/GID='$(id -g)'/' > .env +``` +Then build and run the dev container: +``` +docker-compose -f docker-compose.dev.yml build --no-cache --pull +docker-compose -f docker-compose.dev.yml run --rm -u node app npm run postinstall +docker-compose -f docker-compose.dev.yml up +``` +Dev Selfoss web interface will be available at http://localhost:8391, and you can run all the dev scripts like this: `docker-compose exec -u node npm run check` or simply jump into bash inside the container: `docker-compose exec -u node bash`. That's it, you can start developing! From 11031d96b6f09a9cda24034a4e593ed69ab19484 Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Sun, 16 Feb 2020 13:27:17 +0100 Subject: [PATCH 7/9] removing dockerignore --- .dockerignore | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 8bb7f0dd9e..0000000000 --- a/.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -/assets/.cache -/data/favicons/*.png -/data/favicons/*.jpg -/data/thumbnails/*.png -/data/thumbnails/*.jpg -/data/cache/*.spc -/data/logs/*.log -/data/sqlite/*.db -/public -user.css -user.js -config.ini -node_modules -.env -vendor/ -.php_cs.cache From 3d8fd32ae6957db842d18ea6da3b907075ffa94f Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Sun, 16 Feb 2020 14:42:27 +0100 Subject: [PATCH 8/9] moved docker-compose files into utils/docker --- .env.dist => utils/docker/.env.dist | 0 utils/docker/Dockerfile.dev | 3 +-- utils/docker/Readme.md | 8 ++++++-- .../docker/docker-compose.dev.yml | 3 ++- docker-compose.yml => utils/docker/docker-compose.yml | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) rename .env.dist => utils/docker/.env.dist (100%) rename docker-compose.dev.yml => utils/docker/docker-compose.dev.yml (86%) rename docker-compose.yml => utils/docker/docker-compose.yml (93%) diff --git a/.env.dist b/utils/docker/.env.dist similarity index 100% rename from .env.dist rename to utils/docker/.env.dist diff --git a/utils/docker/Dockerfile.dev b/utils/docker/Dockerfile.dev index 67effc721f..301d69b6bb 100644 --- a/utils/docker/Dockerfile.dev +++ b/utils/docker/Dockerfile.dev @@ -20,8 +20,7 @@ RUN curl -o /tmp/composer-setup.php "https://getcomposer.org/installer"; \ && groupadd --gid ${gid} node \ && useradd --uid ${uid} --gid node --shell /bin/bash --create-home node -ENV APACHE_RUN_USER=node -ENV APACHE_RUN_GROUP=node +ENV APACHE_RUN_USER=node APACHE_RUN_GROUP=node VOLUME /var/www/html/ diff --git a/utils/docker/Readme.md b/utils/docker/Readme.md index 6a026ed545..f2c07181f4 100644 --- a/utils/docker/Readme.md +++ b/utils/docker/Readme.md @@ -2,7 +2,9 @@ There are two Dockerfiles bundled in the repository - one for development, one for production deployment. -To build the production container use: +### Production + +To build the production container first go to utils/docker directory, then use: ``` docker-compose build --no-cache --pull ``` @@ -16,7 +18,9 @@ Selfoss web interface will be available at http://localhost:8390 Selfoss config is mounted in a separate volume, so your custom settings should survive reboot. -To run the development container first copy .env.dist into .env and make sure the UID and GID matches your own user and group ID, otherwise the dev scripts will create files with wrong access rights. +### Development + +To run the development container first make sure you are in utils/docker directory, then copy .env.dist into .env and make sure the UID and GID matches your own user and group ID, otherwise the dev scripts will create files with wrong access rights. ``` cat .env.dist | sed 's/UID=1000/UID='$(id -u)'/' | sed 's/GID=1000/GID='$(id -g)'/' > .env ``` diff --git a/docker-compose.dev.yml b/utils/docker/docker-compose.dev.yml similarity index 86% rename from docker-compose.dev.yml rename to utils/docker/docker-compose.dev.yml index c1bfea011b..439d05c4fb 100644 --- a/docker-compose.dev.yml +++ b/utils/docker/docker-compose.dev.yml @@ -3,11 +3,12 @@ version: "3" services: # clean build with `docker-compose -f docker-compose.dev.yml build --no-cache --pull app` app: + image: selfoss/selfoss-dev build: args: uid: ${UID} gid: ${GID} - context: . + context: ../.. dockerfile: ./utils/docker/Dockerfile.dev volumes: - .:/var/www/html/ diff --git a/docker-compose.yml b/utils/docker/docker-compose.yml similarity index 93% rename from docker-compose.yml rename to utils/docker/docker-compose.yml index f028bf42ca..3325de5847 100644 --- a/docker-compose.yml +++ b/utils/docker/docker-compose.yml @@ -5,7 +5,7 @@ services: app: image: selfoss/selfoss build: - context: . + context: ../.. dockerfile: ./utils/docker/Dockerfile volumes: - config:/var/www/html/config/ From f7786f93acc5a4a83fa45a0a0950325b6cbf9c50 Mon Sep 17 00:00:00 2001 From: squatica <53292272+squatica@users.noreply.github.com> Date: Sat, 16 May 2020 11:13:04 +0200 Subject: [PATCH 9/9] [WIP] Hi guys, I'm still alive. I rebased this PR on top of the current master & solved the conflicts. I'm looking into @kolaente's remarks, it should be possible so I'll do it. Unfortunately I lost access to my email and github started asking for email verification, so I cannot login to github web, but I can still commit. Hopefully the support will let me recover the account. If not then I'll have to continue under different username. --- utils/docker/Dockerfile.dev | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/docker/Dockerfile.dev b/utils/docker/Dockerfile.dev index 301d69b6bb..c2ccfee6ce 100644 --- a/utils/docker/Dockerfile.dev +++ b/utils/docker/Dockerfile.dev @@ -1,5 +1,8 @@ FROM php:7.4-apache-buster +# TODO: basically this image should be built on top of the production image +# replacing the source dir with mounted volume + ARG gid ARG uid