Revert "Improve paths for Docker (#42)"

This reverts commit 39ea593879.
This commit is contained in:
Pere Orga 2021-08-14 20:23:21 +02:00
parent 39ea593879
commit 19f4fc2918
7 changed files with 27 additions and 36 deletions

View File

@ -6,6 +6,11 @@ RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?note=$1
Header set X-Robots-Tag: "noindex, nofollow"
</IfModule>
<Files "docker-compose.yml">
Order Allow,Deny
Deny from all
</Files>
# Uncomment the lines below to enable basic authentication.
# See https://httpd.apache.org/docs/current/programs/htpasswd.html for generating your .htpasswd

View File

@ -1,5 +1,11 @@
FROM php:7.4-apache
ENV APP_PATH /var/www/minimalist-web-notepad
# Set Apache DocumentRoot to APP_PATH
RUN sed -ri -e 's!/var/www/html!${APP_PATH}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APP_PATH}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Set PHP configuration to production
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
@ -7,9 +13,17 @@ RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN a2enmod rewrite
# Import App
COPY .htaccess index.php styles.css script.js favicon.ico notes.htaccess ./
WORKDIR $APP_PATH
ADD . $APP_PATH
# Set entrypoint for permissions
COPY minimalist-web-notepad-entrypoint /usr/local/bin/
ENTRYPOINT ["minimalist-web-notepad-entrypoint"]
CMD ["apache2-foreground"]
# Remove default URL from configuration in $base_url
RUN sed -ri -e 's!https://notes.orga.cat!!g' $APP_PATH/index.php
# Set access rights for Apache
RUN chown -R www-data:www-data $APP_PATH/_tmp
# Create volumes
VOLUME $APP_PATH/_tmp
# Expose port 80
EXPOSE 80

View File

@ -45,27 +45,13 @@ docker build -t minimalist-web-notepad .
Start the container:
```
docker run -d --name minimalist-web-notepad -p 80:80 minimalist-web-notepad
```
Show logs:
```
docker logs -f minimalist-web-notepad
```
Stop the container:
```
docker stop minimalist-web-notepad
docker run -itd --name minimalist-web-notepad -p 80:80 minimalist-web-notepad
```
Alternatively, docker-compose can also be used:
```
docker-compose up -d
```
and
```
docker-compose down
```
#### Environment variables

View File

@ -7,7 +7,7 @@ services:
ports:
- "80:80"
volumes:
- minimalist-web-notepad:/var/www/html/_tmp
- minimalist-web-notepad:/var/www/minimalist-web-notepad/_tmp
volumes:
minimalist-web-notepad:

View File

@ -1,7 +1,7 @@
<?php
// Base URL of the website, without trailing slash.
$base_url = getenv('MWN_BASE_URL') ?: '';
$base_url = getenv('MWN_BASE_URL') ?: 'https://notes.orga.cat';
// Path to the directory to save the notes in, without trailing slash.
// Should be outside of the document root, if possible.

View File

@ -1,14 +0,0 @@
#!/bin/sh
set -e
# Create save path
case "${MWN_SAVE_PATH:=_tmp}" in
/*) NOTES_PATH="$MWN_SAVE_PATH" ;;
*) NOTES_PATH="/var/www/html/$MWN_SAVE_PATH" ;;
esac
mkdir -p "$NOTES_PATH"
cp "/var/www/html/notes.htaccess" "$NOTES_PATH/.htaccess"
chown -R www-data:www-data "$NOTES_PATH"
# Run default entrypoint
exec docker-php-entrypoint "$@"