Open akash07k opened 4 years ago
That will depend on what you want to use the Docker image for.
If you want to use if for running selfoss on production, you do not need node, you can use one of the prebuilt archives in https://github.com/SSilence/selfoss#download and copy one of the existing Dockerfiles from Docker Hub:
If you want to use it for development, I do not think docker-compose is necessary for node. The JavaScript assets are served by the web server so I would expect them to reside in the same image. You could install Node in the Dockerfile just like PHP and other stuff is.
If you want to use database other than SQLite, then docker-compose might be useful to orchestrate the communication between the PHP server and the DB server but it is not necessary either. Or if you want to use PHP-FPM.
I'm actually currently preparing a Dockerfile for selfoss with the intention to send a PR. As @jtojnar said there are two main scenarios - you either want the "production" image which contains app sources inside, or a "dev" image which only contains dev dependencies and tools, but sources are mounted to your filesystem. This is what I have so far for the production image (uses the stable tag 2.18), dev image coming soon.
FROM ubuntu:bionic as source
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
git ca-certificates \
&& git clone https://github.com/SSilence/selfoss.git && cd selfoss \
&& git checkout 2.18
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:12-stretch as npm
COPY --from=composer /selfoss /selfoss
RUN cd /selfoss && npm i && ./node_modules/.bin/grunt client:install
FROM php:7.3-apache-stretch
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 cp defaults.ini config.ini \
&& a2enmod rewrite \
&& 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 /var/www/html/public \
&& echo -e "#!/bin/bash\nwhile true; do php /var/www/html/cliupdate.php; sleep 900; done;" > /check.sh && chmod a+x /check.sh
CMD [ "bash", "-c", "/check.sh & apache2-foreground" ]
You can build and use it directly, but here is a simple docker-compose.yml just to mount the volume with data and port. (You may need to re-run the chown command after your data volume is mounted for the first time, that's still one of my TODO items)
version: "3"
services:
web:
build: .
volumes:
- data:/var/www/html/data
ports:
- "8897:80"
volumes:
data:
I'm actually currently preparing a Dockerfile for selfoss with the intention to send a PR. As @jtojnar said there are two main scenarios - you either want the "production" image which contains app sources inside, or a "dev" image which only contains dev dependencies and tools, but sources are mounted to your filesystem. This is what I have so far for the production image (uses the stable tag 2.18), dev image coming soon.
FROM ubuntu:bionic as source RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ git ca-certificates \ && git clone https://github.com/SSilence/selfoss.git && cd selfoss \ && git checkout 2.18 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:12-stretch as npm COPY --from=composer /selfoss /selfoss RUN cd /selfoss && npm i && ./node_modules/.bin/grunt client:install FROM php:7.3-apache-stretch 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 cp defaults.ini config.ini \ && a2enmod rewrite \ && 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 /var/www/html/public \ && echo -e "#!/bin/bash\nwhile true; do php /var/www/html/cliupdate.php; sleep 900; done;" > /check.sh && chmod a+x /check.sh CMD [ "bash", "-c", "/check.sh & apache2-foreground" ]
You can build and use it directly, but here is a simple docker-compose.yml just to mount the volume with data and port. (You may need to re-run the chown command after your data volume is mounted for the first time, that's still one of my TODO items)
version: "3" services: web: build: . volumes: - data:/var/www/html/data ports: - "8897:80" volumes: data: ```Wow excellent, going to try this dockerfile. Waiting for your dev dockerfile eagerly because I'm more willing to use it for development because the production version is quite outdated now. I've spent the whole day today in making selfoss work with docker but no luck at all, Hope yours work perfectly. Thanks a lot for the help and looking forward to try the dev dockerfile too
I'm actually currently preparing a Dockerfile for selfoss with the intention to send a PR. As @jtojnar said there are two main scenarios - you either want the "production" image which contains app sources inside, or a "dev" image which only contains dev dependencies and tools, but sources are mounted to your filesystem. This is what I have so far for the production image (uses the stable tag 2.18), dev image coming soon.
FROM ubuntu:bionic as source RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ git ca-certificates \ && git clone https://github.com/SSilence/selfoss.git && cd selfoss \ && git checkout 2.18 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:12-stretch as npm COPY --from=composer /selfoss /selfoss RUN cd /selfoss && npm i && ./node_modules/.bin/grunt client:install FROM php:7.3-apache-stretch 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 cp defaults.ini config.ini \ && a2enmod rewrite \ && 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 /var/www/html/public \ && echo -e "#!/bin/bash\nwhile true; do php /var/www/html/cliupdate.php; sleep 900; done;" > /check.sh && chmod a+x /check.sh CMD [ "bash", "-c", "/check.sh & apache2-foreground" ]
You can build and use it directly, but here is a simple docker-compose.yml just to mount the volume with data and port. (You may need to re-run the chown command after your data volume is mounted for the first time, that's still one of my TODO items)
version: "3" services: web: build: . volumes: - data:/var/www/html/data ports: - "8897:80" volumes: data:
No luck with both the files. In second dockerfile, I always get (localhost sent an empty response.). Going to try @squatica 's dockerfile and let's see how it goes. :-)
I'm actually currently preparing a Dockerfile for selfoss with the intention to send a PR. As @jtojnar said there are two main scenarios - you either want the "production" image which contains app sources inside, or a "dev" image which only contains dev dependencies and tools, but sources are mounted to your filesystem. This is what I have so far for the production image (uses the stable tag 2.18), dev image coming soon.
FROM ubuntu:bionic as source RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ git ca-certificates \ && git clone https://github.com/SSilence/selfoss.git && cd selfoss \ && git checkout 2.18 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:12-stretch as npm COPY --from=composer /selfoss /selfoss RUN cd /selfoss && npm i && ./node_modules/.bin/grunt client:install FROM php:7.3-apache-stretch 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 cp defaults.ini config.ini \ && a2enmod rewrite \ && 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 /var/www/html/public \ && echo -e "#!/bin/bash\nwhile true; do php /var/www/html/cliupdate.php; sleep 900; done;" > /check.sh && chmod a+x /check.sh CMD [ "bash", "-c", "/check.sh & apache2-foreground" ]
You can build and use it directly, but here is a simple docker-compose.yml just to mount the volume with data and port. (You may need to re-run the chown command after your data volume is mounted for the first time, that's still one of my TODO items)
version: "3" services: web: build: . volumes: - data:/var/www/html/data ports: - "8897:80" volumes: data:
@squatica Unfortunately it didn't work either. Same issue as mine images:
Some more errors:
@squatica
@akash07k All right, I cleaned it up here: https://github.com/squatica/selfoss-docker Both 2.18 and master versions are there.
@akash07k All right, I cleaned it up here: https://github.com/squatica/selfoss-docker Both 2.18 and master versions are there.
@squatica Thanks a lot, it works. Now I'm trying to update the PHP image and other stuff and will see whether it works or not. I'm really grateful for your efforts on this
@squatica Any updates buddy? I know that you are busy, but still thought to ask.
Based on the link (https://hub.docker.com/r/pamplemousse/selfoss/dockerfile) above I managed to get it packaged into a docker-compose including a MySql database and also including my Webfront. Have a look here: https://github.com/MatthK/swfd
For the newly released selfoss 2.19, we are recommending https://gitlab.com/radek-sprta/docker-selfoss. It uses a proper service manager, which was something I was missing from the other approaches.
We might still have an official image in the future but I currently do not have the capacity to push it to meet the project requirements. I would still like to thank everyone who worked on this.
I want to dockerize selfoss, but I'm unable to identify that how exactly I do it since it uses PHP and nodejs both. If I require to use docker-compose, then can someone please help me with the exact proper script?