Browse Source

first commit

main
hellodk34 3 years ago
parent
commit
16f2f0162a
  1. 31
      000-default.conf
  2. 43
      Dockerfile
  3. 26
      README.md
  4. 12
      entrypoint.sh

31
000-default.conf

@ -0,0 +1,31 @@
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
# ServerName demo.site
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

43
Dockerfile

@ -0,0 +1,43 @@
FROM php:8.1-apache
MAINTAINER hellodk <[email protected]>
RUN a2enmod rewrite
# 使用 ustc 镜像加速
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && \
apt-get clean
# 安装相关拓展
RUN apt update && apt install imagemagick libmagickwand-dev -y \
&& pecl install imagick \
&& docker-php-ext-install bcmath \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-enable imagick
RUN { \
echo 'post_max_size = 100M;';\
echo 'upload_max_filesize = 100M;';\
echo 'max_execution_time = 600S;';\
} > /usr/local/etc/php/conf.d/docker-php-upload.ini;
RUN { \
echo 'opcache.enable=1'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=10000'; \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.save_comments=1'; \
echo 'opcache.revalidate_freq=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
\
echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \
\
echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \
\
mkdir -p /var/www/data; \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www
COPY ./ /var/www/lsky/
COPY ./000-default.conf /etc/apache2/sites-enabled/
COPY entrypoint.sh /
WORKDIR /var/www/html
VOLUME /var/www/html
EXPOSE 80
RUN chmod a+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apachectl","-D","FOREGROUND"]

26
README.md

@ -1,2 +1,28 @@
# lsky-pro-docker
Lsky Pro 兰空图床 docker 镜像,适用于 Linux arm64 和 amd64 架构。
---
我看 GitHub 上有好几个 lsky-pro-docker repo 了(名字类似),虽说是开源了 Dockerfile,但是使用这些资源是不够的(也就是说,你通过这些开源的资源,docker build,虽然镜像能成功创建,但是容器启动后程序无法运行)。所以我新建了此 repo。详细的记录一下 Lsky Pro 镜像应该如何构建。而且简单学习了一下 docker 多架构构建,现分享出来。
docker 镜像构建关键的三个文件
- 000-default.conf
- Dockerfile
- entrypoint.sh
这三个文件在本仓库有。
然后很重要的一点是使用 composer 安装 `composer.json` 指定的依赖。
在构建的机器上安装 `php8.1` 以及 `composer v2.3.5`。在项目根目录执行 `composer install` 安装依赖。
源程序推荐通过 GitHub Release 页面发布的稳定版下载。
多架构构建需要用到 `buildx` 工具,这是一个 docker cli 插件,提供了在一台机器上构建其他平台程序的能力。
镜像构建的过程我写了几篇博客,需要详细了解可阅读
- [斐讯 N1 Debian9 安装 php8.1 和 composer](https://hellodk.cn/post/1032)
- [构建 arm64 架构和 amd64 架构的兰空图床 docker 镜像](https://hellodk.cn/post/1034)
- [Docker 构建多架构镜像实战 构建 amd64 和 arm64 架构的兰空图床镜像](https://hellodk.cn/post/1037)

12
entrypoint.sh

@ -0,0 +1,12 @@
#!/bin/bash
set -eu
if [ ! -e '/var/www/html/public/index.php' ]; then
cp -a /var/www/lsky/* /var/www/html/
cp -a /var/www/lsky/.env.example /var/www/html
fi
chown -R www-data /var/www/html
chgrp -R www-data /var/www/html
chmod -R 755 /var/www/html/
exec "$@"
Loading…
Cancel
Save