Skip to content
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

Docker with volumes #1243

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move default path from /var/www to /var/www/html. /var/www is owned b…
…y root and makes all the population of the data on first run complicated. We could change the owner of /var/www but if the image from already provides a folder for html I decided to honour it
guanana committed Jun 1, 2023
commit 5fb012e88fae2b39dfcc3231c020e338838554e2
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ services:
dockerfile: Dockerfile
image: crater-php
restart: unless-stopped
working_dir: /var/www/
working_dir: /var/www/html/
volumes:
- ./:/var/www
- ./docker-compose/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:rw,delegated
2 changes: 1 addition & 1 deletion docker-compose/crontab
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* * * * * cd /var/www && php artisan schedule:run >> /dev/stdout 2>&1
* * * * * cd /var/www/html && php artisan schedule:run >> /dev/stdout 2>&1
2 changes: 1 addition & 1 deletion docker-compose/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ server {
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
root /var/www/html/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
18 changes: 9 additions & 9 deletions uffizzi/Dockerfile
Original file line number Diff line number Diff line change
@@ -32,33 +32,33 @@ RUN mkdir -p /home/crater-user/.composer && \
chown -R crater-user:crater-user /home/crater-user

# Mounted volumes
COPY ./ /var/www
COPY ./ /var/www/html/
COPY ./docker-compose/php/uploads.ini /usr/local/etc/php/conf.d/uploads.ini
COPY ./uffizzi/.env.example /var/www/.env
COPY ./uffizzi/.env.example /var/www/html/.env

# Set working directory
WORKDIR /var/www
WORKDIR /var/www/html/

RUN chown -R crater-user:crater-user ./
RUN chmod -R 775 composer.json composer.lock \
RUN chmod -R 775 composer.json composer.lock \
composer.lock storage/framework/ \
storage/logs/ bootstrap/cache/ /home/crater-user/.composer
RUN chown -R $(whoami):$(whoami) /var/log/
RUN chmod -R 775 /var/log

# Cleanup manually generated build files
RUN rm -rf /var/www/public/build
RUN rm -rf /var/www/html/public/build
RUN npm config set user 0
RUN npm config set unsafe-perm true
# Frontend bulding
RUN sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' /var/www/.env
RUN sed -i 's/DB_DATABASE=crater/DB_DATABASE=\/tmp\/crater.sqlite/g' /var/www/.env
RUN sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' /var/www/html/.env
RUN sed -i 's/DB_DATABASE=crater/DB_DATABASE=\/tmp\/crater.sqlite/g' /var/www/html/.env
RUN touch /tmp/crater.sqlite
RUN composer install --no-interaction --prefer-dist
RUN npm i -f
RUN npm install --save-dev sass
RUN export NODE_OPTIONS="--max-old-space-size=4096" && /usr/bin/npx vite build --target=es2020
RUN sed -i 's/DB_CONNECTION=sqlite/DB_CONNECTION=mysql/g' /var/www/.env
RUN sed -i 's/DB_DATABASE=\/tmp\/crater.sqlite/DB_DATABASE=crater/g' /var/www/.env
RUN sed -i 's/DB_CONNECTION=sqlite/DB_CONNECTION=mysql/g' /var/www/html/.env
RUN sed -i 's/DB_DATABASE=\/tmp\/crater.sqlite/DB_DATABASE=crater/g' /var/www/html/.env

USER crater-user
14 changes: 7 additions & 7 deletions uffizzi/crond/Dockerfile
Original file line number Diff line number Diff line change
@@ -31,15 +31,15 @@ RUN mkdir -p /home/crater-user/.composer && \
chown -R crater-user:crater-user /home/crater-user

# Mounted volumes
COPY ./ /var/www
COPY ./ /var/www/html
COPY ./docker-compose/php/uploads.ini /usr/local/etc/php/conf.d/uploads.ini
COPY ./uffizzi/.env.example /var/www/.env
COPY ./uffizzi/.env.example /var/www/html/.env

# Set working directory
WORKDIR /var/www
WORKDIR /var/www/html

RUN chown -R crater-user:crater-user ./
RUN chmod -R 775 composer.json composer.lock \
RUN chmod -R 775 composer.json composer.lock \
composer.lock storage/framework/ \
storage/logs/ bootstrap/cache/ /home/crater-user/.composer

@@ -58,10 +58,10 @@ RUN docker-php-ext-install pdo pdo_mysql bcmath
COPY docker-compose/crontab /etc/crontabs/root

# Mounted volumes
COPY --from=build /var/www /var/www
COPY --from=build /var/www/html /var/www/html

RUN chown -R $(whoami):$(whoami) /var/www/
RUN chmod -R 775 /var/www/
RUN chown -R $(whoami):$(whoami) /var/www/html/
RUN chmod -R 775 /var/www/html/
RUN chown -R $(whoami):$(whoami) /var/log/
RUN chmod -R 775 /var/log/

12 changes: 6 additions & 6 deletions uffizzi/docker-compose.uffizzi.yml
Original file line number Diff line number Diff line change
@@ -9,12 +9,12 @@ services:
app:
image: "${APP_IMAGE}"
restart: unless-stopped
working_dir: /var/www/
working_dir: /var/www/html/
command: ["-c","
composer config --no-plugins allow-plugins.pestphp/pest-plugin true &&
composer install --no-interaction --prefer-dist --optimize-autoloader &&
php artisan storage:link || true &&
php artisan key:generate --force &&
composer config --no-plugins allow-plugins.pestphp/pest-plugin true &&
composer install --no-interaction --prefer-dist --optimize-autoloader &&
php artisan storage:link || true &&
php artisan key:generate --force &&
php-fpm",
]
entrypoint: /bin/sh
@@ -54,5 +54,5 @@ services:
cron:
image: "${CROND_IMAGE}"
restart: always


2 changes: 1 addition & 1 deletion uffizzi/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -5,5 +5,5 @@ FROM nginx:1.17-alpine

RUN rm /etc/nginx/conf.d/default.conf

COPY --from=build /var/www /var/www
COPY --from=build /var/www/html /var/www/html
COPY ./uffizzi/nginx/nginx /etc/nginx/conf.d/
2 changes: 1 addition & 1 deletion uffizzi/nginx/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ server {
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
root /var/www/html/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;