From cca7e6fe396347dd38e7784b0d56f750408e5eeb Mon Sep 17 00:00:00 2001 From: HalcyonAzure Date: Fri, 21 Apr 2023 13:30:48 +0800 Subject: [PATCH] fix. replace readme --- 000-default.conf.template | 2 +- Dockerfile | 11 +++++------ README.md | 7 +++++++ docker-compose.yaml | 33 ++++++++++++++++++++++++++++----- entrypoint.sh | 6 ++++-- ports.conf.template | 2 +- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/000-default.conf.template b/000-default.conf.template index 8c916e36..c362cf2a 100644 --- a/000-default.conf.template +++ b/000-default.conf.template @@ -1,4 +1,4 @@ - + # 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 diff --git a/Dockerfile b/Dockerfile index 00ee0b32..e91af1a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,10 @@ FROM php:8.1-apache # 安装相关拓展 ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ -RUN a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \ +RUN apt-get update && \ + apt-get install -y gettext && \ + apt-get clean && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && \ + a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \ install-php-extensions imagick bcmath pdo_mysql pdo_pgsql redis && \ \ { \ @@ -30,17 +33,13 @@ RUN a2enmod rewrite && chmod +x /usr/local/bin/install-php-extensions && \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www -RUN apt-get update && \ - apt-get install -y gettext && \ - rm -rf /var/lib/apt/lists/* - COPY ./ /var/www/lsky/ COPY ./000-default.conf.template /etc/apache2/sites-enabled/ COPY ./ports.conf.template /etc/apache2/ COPY entrypoint.sh / WORKDIR /var/www/html/ VOLUME /var/www/html -EXPOSE 80 +ENV WEB_PORT 8089 RUN chmod a+x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["apachectl","-D","FOREGROUND"] diff --git a/README.md b/README.md index 92ecc8f9..fb56cd31 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,14 @@ docker run -d \ --restart unless-stopped \ -p 9080:80 \ -v /path-to-data:/var/www/html \ + -e WEB_PORT=8089 \ halcyonazure/lsky-pro-docker:latest ``` +## 环境变量 + +目前该容器只有一个环境变量:`WEB_PORT`,用于指定容器内的`Apache`监听的端口,默认为`8089`,如果需要修改的话可以在启动容器时添加`-e WEB_PORT=8089`来指定端口 + ### Windows内以`WSL`的方式部署`Docker`容器 按照 [#13](https://github.com/HalcyonAzure/lsky-pro-docker/issues/13) 的反馈来看,如果在`Windows`内创建容器出现了将文件挂载于`WSL`内,然后出现了重启系统文件未识别的情况,可以将映射目录修改为类似`\\wsl$\Ubuntu\path-mount-lsky\`的形式 @@ -39,6 +44,8 @@ services: restart: unless-stopped hostname: lskypro container_name: lskypro + environment: + - WEB_PORT=8089 volumes: - /data/lsky/web:/var/www/html/ ports: diff --git a/docker-compose.yaml b/docker-compose.yaml index 2d10a86e..e433652d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,14 +1,37 @@ version: '3' services: lskypro: - build: . - image: lsky-pro-docker:test + image: halcyonazure/lsky-pro-docker:latest restart: unless-stopped hostname: lskypro container_name: lskypro + environment: + - WEB_PORT=8089 volumes: - /data/lsky/web:/var/www/html/ - environment: - - APACHE_PORT=8876 ports: - - "9080:8876" \ No newline at end of file + - "9080:8089" + networks: + - lsky-net + + mysql-lsky: + image: mysql:5.7.22 + restart: unless-stopped + # 主机名,可作为"数据库连接地址" + hostname: mysql-lsky + # 容器名称 + container_name: mysql-lsky + # 修改加密规则 + command: --default-authentication-plugin=mysql_native_password + volumes: + - /data/lsky/mysql/data:/var/lib/mysql + - /data/lsky/mysql/conf:/etc/mysql + - /data/lsky/mysql/log:/var/log/mysql + environment: + MYSQL_ROOT_PASSWORD: lAsWjb6rzSzENUYg # 数据库root用户密码,自行修改 + MYSQL_DATABASE: lsky-data # 可作为"数据库名称/路径" + networks: + - lsky-net + +networks: + lsky-net: {} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index ae96b443..d7d2911a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,10 @@ #!/bin/bash set -eu -envsubst '${APACHE_PORT}' < /etc/apache2/sites-enabled/000-default.conf.template > /etc/apache2/sites-enabled/000-default.conf -envsubst '${APACHE_PORT}' < /etc/apache2/ports.conf.template > /etc/apache2/ports.conf +WEB_PORT = ${WEB_PORT:-8089} + +envsubst '${WEB_PORT}' < /etc/apache2/sites-enabled/000-default.conf.template > /etc/apache2/sites-enabled/000-default.conf +envsubst '${WEB_PORT}' < /etc/apache2/ports.conf.template > /etc/apache2/ports.conf if [ ! -e '/var/www/html/public/index.php' ]; then cp -a /var/www/lsky/* /var/www/html/ diff --git a/ports.conf.template b/ports.conf.template index ca1cf93c..477b3d4b 100644 --- a/ports.conf.template +++ b/ports.conf.template @@ -1 +1 @@ -Listen ${APACHE_PORT} \ No newline at end of file +Listen ${WEB_PORT} \ No newline at end of file