-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from mineadmin/2.0.x-dev
fixed dockerfile
- Loading branch information
Showing
3 changed files
with
105 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
FROM hyperf/hyperf:8.1-alpine-v3.18-swoole | ||
LABEL maintainer="MineManage Developers <[email protected]>" version="1.0" license="MIT" app.name="MineManage" | ||
|
||
## | ||
# ---------- env settings ---------- | ||
## | ||
# --build-arg timezone=Asia/Shanghai | ||
ARG timezone | ||
|
||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ | ||
APP_ENV=prod \ | ||
SCAN_CACHEABLE=(true) | ||
|
||
# update | ||
RUN set -ex \ | ||
# show php version and extensions | ||
&& php -v \ | ||
&& php -m \ | ||
&& php --ri swoole \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php* \ | ||
# - config PHP | ||
&& { \ | ||
echo "upload_max_filesize=128M"; \ | ||
echo "post_max_size=128M"; \ | ||
echo "memory_limit=1G"; \ | ||
echo "date.timezone=${TIMEZONE}"; \ | ||
} | tee conf.d/99_overrides.ini \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
# ---------- clear works ---------- | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
# update | ||
RUN set -ex \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php81 \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
RUN set -ex && \ | ||
apk update \ | ||
&& apk add --no-cache libstdc++ openssl git bash autoconf pcre2-dev zlib-dev re2c gcc g++ make \ | ||
php81-pear php81-dev php81-tokenizer php81-fileinfo php81-simplexml php81-xmlwriter \ | ||
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev libaio-dev openssl-dev curl-dev c-ares-dev \ | ||
&& pecl channel-update pecl.php.net \ | ||
&& pecl install --configureoptions 'enable-reader="yes"' xlswriter \ | ||
&& echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \ | ||
&& php -m \ | ||
&& php -v \ | ||
&& php --ri swoole \ | ||
&& mkdir -p /app-src \ | ||
# ---------- clear works ---------- | ||
&& apk del .build-deps \ | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so | ||
|
||
WORKDIR /opt/www | ||
|
||
EXPOSE 9501 9502 9503 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Build Docker | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build | ||
run: cp -rf .github/workflows/Dockerfile . && docker build -t hyperf . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,55 @@ | ||
# Default Dockerfile | ||
|
||
ARG ALPINE_VERSION=3.15 | ||
|
||
FROM alpine:$ALPINE_VERSION | ||
|
||
FROM hyperf/hyperf:8.1-alpine-v3.18-swoole | ||
LABEL maintainer="MineManage Developers <[email protected]>" version="1.0" license="MIT" app.name="MineManage" | ||
|
||
ARG ALPINE_VERSION=3.15 | ||
|
||
# trust this project public key to trust the packages. | ||
ADD https://php.hernandev.com/key/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub | ||
|
||
## | ||
# ---------- building ---------- | ||
# ---------- env settings ---------- | ||
## | ||
RUN set -ex \ | ||
# change apk source repo | ||
&& echo "https://php.hernandev.com/v$ALPINE_VERSION/php-8.1" >> /etc/apk/repositories \ | ||
&& echo "@php https://php.hernandev.com/v$ALPINE_VERSION/php-8.1" >> /etc/apk/repositories \ | ||
&& apk update \ | ||
&& apk add --no-cache \ | ||
# Install base packages ('ca-certificates' will install 'nghttp2-libs') | ||
ca-certificates \ | ||
curl \ | ||
wget \ | ||
tar \ | ||
xz \ | ||
libressl \ | ||
tzdata \ | ||
pcre \ | ||
php8 \ | ||
php8-bcmath \ | ||
php8-curl \ | ||
php8-ctype \ | ||
php8-dom \ | ||
php8-gd \ | ||
php8-iconv \ | ||
php8-mbstring \ | ||
php8-mysqlnd \ | ||
php8-openssl \ | ||
php8-pdo \ | ||
php8-pdo_mysql \ | ||
php8-pdo_sqlite \ | ||
php8-phar \ | ||
php8-posix \ | ||
php8-redis \ | ||
php8-sockets \ | ||
php8-sodium \ | ||
php8-sysvshm \ | ||
php8-sysvmsg \ | ||
php8-sysvsem \ | ||
php8-zip \ | ||
php8-zlib \ | ||
php8-xml \ | ||
php8-xmlreader \ | ||
php8-pcntl \ | ||
php8-opcache \ | ||
&& ln -sf /usr/bin/php8 /usr/bin/php \ | ||
&& apk del --purge *-dev \ | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php8 \ | ||
&& php -v \ | ||
&& php -m \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
# --build-arg timezone=Asia/Shanghai | ||
ARG timezone | ||
|
||
ARG COMPOSER_VERSION=2.3.10 | ||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ | ||
APP_ENV=prod \ | ||
SCAN_CACHEABLE=(true) | ||
|
||
# update | ||
RUN set -ex \ | ||
&& apk update \ | ||
# for extension libaio linux-headers | ||
&& apk add --no-cache libstdc++ openssl git bash php8-pear php8-dev autoconf pcre2-dev c-ares-dev zlib-dev re2c gcc g++ make \ | ||
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev curl-dev \ | ||
# php extension:swoole | ||
&& ln -s /usr/bin/pecl8 /usr/local/bin/pecl \ | ||
&& pecl channel-update pecl.php.net \ | ||
&& pecl install --configureoptions 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="no" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="no"' swoole \ | ||
&& {\ | ||
echo "memory_limit=1G"; \ | ||
echo "upload_max_filesize=128M"; \ | ||
echo "post_max_size=128M"; \ | ||
echo "memory_limit=1G"; \ | ||
echo "date.timezone=Asia/Shanghai"; \ | ||
} | tee /etc/php8/conf.d/00_default.ini \ | ||
&& echo "opcache.enable_cli = 'On'" >> /etc/php8/conf.d/00_opcache.ini \ | ||
&&{ \ | ||
echo "extension=swoole.so";\ | ||
echo "swoole.use_shortname = 'Off'";\ | ||
} | tee /etc/php8/conf.d/50_swoole.ini \ | ||
# install composer | ||
&& wget -nv -O /usr/local/bin/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ | ||
&& chmod u+x /usr/local/bin/composer \ | ||
# php info | ||
# show php version and extensions | ||
&& php -v \ | ||
&& php -m \ | ||
&& php --ri swoole \ | ||
&& php --ri Zend\ OPcache \ | ||
&& composer --version \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php* \ | ||
# - config PHP | ||
&& { \ | ||
echo "upload_max_filesize=128M"; \ | ||
echo "post_max_size=128M"; \ | ||
echo "memory_limit=1G"; \ | ||
echo "date.timezone=${TIMEZONE}"; \ | ||
} | tee conf.d/99_overrides.ini \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
# ---------- clear works ---------- | ||
&& apk del .build-deps \ | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \ | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
## | ||
# ---------- env settings ---------- | ||
## | ||
# --build-arg timezone=Asia/Shanghai | ||
ARG timezone | ||
|
||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ | ||
# APP_ENV=dev \ | ||
APP_SYSTEM_ENV=docker \ | ||
SCAN_CACHEABLE=(true) | ||
|
||
# update | ||
RUN set -ex \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php8 \ | ||
&& cd /etc/php81 \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
RUN set -ex apk update \ | ||
RUN set -ex && \ | ||
apk update \ | ||
&& apk add --no-cache libstdc++ openssl git bash autoconf pcre2-dev zlib-dev re2c gcc g++ make \ | ||
php8-pear php8-dev php8-tokenizer php8-fileinfo php8-simplexml php8-xmlwriter \ | ||
php81-pear php81-dev php81-tokenizer php81-fileinfo php81-simplexml php81-xmlwriter \ | ||
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev libaio-dev openssl-dev curl-dev c-ares-dev \ | ||
&& pecl channel-update pecl.php.net \ | ||
&& ln -s /usr/bin/phpize8 /usr/local/bin/phpize \ | ||
&& ln -s /usr/bin/php-config8 /usr/local/bin/php-config \ | ||
&& pecl install --configureoptions 'enable-reader="yes"' xlswriter \ | ||
&& echo "extension=xlswriter.so" >> /etc/php8/conf.d/60-xlswriter.ini \ | ||
&& echo "extension=xlswriter.so" >> /etc/php81/conf.d/60-xlswriter.ini \ | ||
&& php -m \ | ||
&& php -v \ | ||
&& php --ri swoole \ | ||
|
@@ -139,16 +59,8 @@ RUN set -ex apk update \ | |
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
# fix aliyun oss wrong charset: https://github.com/aliyun/aliyun-oss-php-sdk/issues/101 | ||
# https://github.com/docker-library/php/issues/240#issuecomment-762438977 | ||
|
||
RUN apk --no-cache --allow-untrusted --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ add gnu-libiconv gnu-libiconv-dev \ | ||
# ---------- clear works ---------- | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so | ||
|
||
WORKDIR /app-src | ||
WORKDIR /opt/www | ||
|
||
EXPOSE 9501 9502 9503 |