Skip to content

Commit 7eb8d76

Browse files
author
xboard
committed
chore: 修复docker环境该用非root运行时全挂载和sqlite部署报错并减少layers
1 parent 03706c0 commit 7eb8d76

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

.docker/etc/supervisor/supervisord.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[supervisord]
22
nodaemon=true
3+
user=root
34
logfile=/dev/null
45
logfile_maxbytes=0
56
pidfile=/tmp/supervisord.pid
@@ -17,6 +18,7 @@ startretries=10
1718

1819
[program:cron]
1920
command=crond -f -l 8
21+
user=root
2022
stdout_logfile=/dev/stdout
2123
stdout_logfile_maxbytes=0
2224
stderr_logfile=/dev/stderr

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ FROM phpswoole/swoole:php8.1-alpine
22

33
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
44

5-
RUN install-php-extensions pcntl bcmath
6-
7-
RUN apk --no-cache add shadow supervisor nginx sqlite nginx-mod-http-brotli mysql-client git
8-
9-
RUN addgroup -S -g 1001 www && adduser -S -G www -u 1001 www
5+
RUN install-php-extensions pcntl bcmath \
6+
&& apk --no-cache add shadow supervisor nginx sqlite nginx-mod-http-brotli mysql-client git \
7+
&& addgroup -S -g 1000 www && adduser -S -G www -u 1000 www
108
#复制项目文件以及配置文件
119
WORKDIR /www
1210
COPY .docker /
1311
COPY . /www
1412
RUN composer install --optimize-autoloader --no-cache --no-dev \
1513
&& php artisan storage:link \
16-
&& chown -R www:www /www
14+
&& chown -R www:www /www \
15+
&& chmod -R 777 /www
1716

1817
CMD [ "/usr/bin/supervisord", "--nodaemon", "-c" ,"/etc/supervisor/supervisord.conf" ]

init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ wget https://github.com/composer/composer/releases/latest/download/composer.phar
55
php composer.phar install -vvv
66
php artisan xboard:install
77

8-
if [ -f "/etc/init.d/bt" ]; then
9-
chown -R www $(pwd);
8+
if [ -f "/etc/init.d/bt" ] || [ "$docker" ]; then
9+
chown -R www:www $(pwd);
1010
fi

update.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ wget https://github.com/composer/composer/releases/latest/download/composer.phar
1717
php composer.phar update -vvv
1818
php artisan xboard:update
1919

20-
if [ -f "/etc/init.d/bt" ]; then
21-
chown -R www $(pwd);
20+
if [ -f "/etc/init.d/bt" ] || [ "$docker" ]; then
21+
chown -R www:www $(pwd);
2222
fi

update_dev.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ wget https://github.com/composer/composer/releases/latest/download/composer.phar
1818
php composer.phar update -vvv
1919
php artisan xboard:update
2020

21-
if [ -f "/etc/init.d/bt" ]; then
22-
chown -R www $(pwd);
21+
if [ -f "/etc/init.d/bt" ] || [ "$docker" ]; then
22+
chown -R www:www $(pwd);
2323
fi

0 commit comments

Comments
 (0)