-
Notifications
You must be signed in to change notification settings - Fork 345
Docker #1170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
squatica
wants to merge
9
commits into
fossar:master
Choose a base branch
from
squatica:docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Docker #1170
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a5d6d75
squashed commits from @akash07k
f44a6ff
had to upgrade deasync to 0.1.16 otherwise npm failed with "No module…
squatica 66a21a0
"--dev" is obsolete
squatica 987afc0
dockerizing selfoss, fixes #1161
squatica ae802d2
simplified sed replacement
squatica 8b334bb
moved docker instructions into separate Readme
squatica 11031d9
removing dockerignore
squatica 3d8fd32
moved docker-compose files into utils/docker
squatica f7786f9
[WIP]
squatica File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
"install-dependencies:server": "composer install", | ||
"lint:client": "npm run --prefix assets/ lint", | ||
"lint:server": "composer run-script lint", | ||
"test:server": "composer run-script test", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
UID=1000 | ||
GID=1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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 | ||
|
||
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 APACHE_RUN_GROUP=node | ||
|
||
VOLUME /var/www/html/ | ||
|
||
CMD [ "/var/www/html/utils/docker/entrypoint.dev.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## Dockerizing selfoss | ||
|
||
There are two Dockerfiles bundled in the repository - one for development, one for production deployment. | ||
|
||
### Production | ||
|
||
To build the production container first go to utils/docker directory, then 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. | ||
|
||
### 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 | ||
``` | ||
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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: ../.. | ||
dockerfile: ./utils/docker/Dockerfile.dev | ||
volumes: | ||
- .:/var/www/html/ | ||
restart: unless-stopped | ||
ports: | ||
- "8391:80" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "3" | ||
|
||
services: | ||
# clean build with `docker-compose build --no-cache --pull app` | ||
app: | ||
image: selfoss/selfoss | ||
build: | ||
context: ../.. | ||
dockerfile: ./utils/docker/Dockerfile | ||
volumes: | ||
- config:/var/www/html/config/ | ||
restart: unless-stopped | ||
ports: | ||
- "8390:80" | ||
|
||
volumes: | ||
config: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Start the server and dev watcher | ||
( | ||
apache2-foreground & su node -c "npm run dev" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/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 | ||
sed 's#^logger_destination=.*#logger_destination=file:php://stderr#' defaults.ini > 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 | ||
apache2-foreground |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.