Skip to content

Commit

Permalink
chore: 修复docker环境该用非root运行时全挂载和sqlite部署报错并减少layers
Browse files Browse the repository at this point in the history
  • Loading branch information
xboard committed Apr 12, 2024
1 parent 03706c0 commit 6e6b66a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .docker/etc/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[supervisord]
nodaemon=true
user=root
logfile=/dev/null
logfile_maxbytes=0
pidfile=/tmp/supervisord.pid
Expand All @@ -17,6 +18,7 @@ startretries=10

[program:cron]
command=crond -f -l 8
user=root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ FROM phpswoole/swoole:php8.1-alpine

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

RUN install-php-extensions pcntl bcmath

RUN apk --no-cache add shadow supervisor nginx sqlite nginx-mod-http-brotli mysql-client git

RUN addgroup -S -g 1001 www && adduser -S -G www -u 1001 www
RUN install-php-extensions pcntl bcmath \
&& apk --no-cache add shadow supervisor nginx sqlite nginx-mod-http-brotli mysql-client git \
&& addgroup -S -g 1000 www && adduser -S -G www -u 1000 www
#复制项目文件以及配置文件
WORKDIR /www
COPY .docker /
COPY . /www
RUN composer install --optimize-autoloader --no-cache --no-dev \
&& php artisan storage:link \
&& chown -R www:www /www
&& chown -R www:www /www \
&& chmod -R 777 /www

CMD [ "/usr/bin/supervisord", "--nodaemon", "-c" ,"/etc/supervisor/supervisord.conf" ]
2 changes: 1 addition & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ php composer.phar install -vvv
php artisan xboard:install

if [ -f "/etc/init.d/bt" ]; then
chown -R www $(pwd);
chown -R www:www $(pwd);
fi

0 comments on commit 6e6b66a

Please sign in to comment.