-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: upgrade dockerfile #144
Open
soulteary
wants to merge
2
commits into
rryqszq4:master
Choose a base branch
from
soulteary:chore/upgrade-docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,29 +1,68 @@ | ||
FROM nginx:stable-alpine as ngx-php | ||
|
||
COPY config /build/config | ||
COPY src /build/src | ||
COPY third_party /build/third_party | ||
|
||
# Nginx Docker Playground (https://github.com/nginx-with-docker/nginx-docker-playground) | ||
FROM soulteary/prebuilt-nginx-modules:base-1.23.1-alpine AS Builder | ||
RUN apk update && apk --no-cache add curl gcc g++ make musl-dev linux-headers gd-dev geoip-dev libxml2-dev libxslt-dev openssl-dev pcre-dev perl-dev pkgconf zlib-dev libedit-dev ncurses-dev php8-dev php8-embed git unzip argon2-dev | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add OPcache extension |
||
ENV PHP_LIB=/usr/lib | ||
WORKDIR /usr/src | ||
|
||
WORKDIR /build | ||
# Nginx Development Kit (https://github.com/vision5/ngx_devel_kit) | ||
ARG DEVEL_KIT_MODULE_CHECKSUM=e15316e13a7b19a3d2502becbb26043a464a135a | ||
ARG DEVEL_KIT_VERSION=0.3.1 | ||
ARG DEVEL_KIT_NAME=ngx_devel_kit | ||
RUN curl -L "https://github.com/vision5/ngx_devel_kit/archive/v${DEVEL_KIT_VERSION}.tar.gz" -o "v${DEVEL_KIT_VERSION}.tar.gz" && \ | ||
echo "${DEVEL_KIT_MODULE_CHECKSUM} v${DEVEL_KIT_VERSION}.tar.gz" | shasum -c && \ | ||
tar -zxC /usr/src -f v${DEVEL_KIT_VERSION}.tar.gz && \ | ||
mv ${DEVEL_KIT_NAME}-${DEVEL_KIT_VERSION}/ ${DEVEL_KIT_NAME} | ||
|
||
RUN apk --no-cache add curl gcc g++ make musl-dev linux-headers gd-dev geoip-dev libxml2-dev libxslt-dev openssl-dev paxmark pcre-dev perl-dev pkgconf zlib-dev libedit-dev ncurses-dev php7-dev php7-embed argon2-dev \ | ||
&& NGINX_VERSION=$(nginx -v 2>&1 | sed 's/^[^0-9]*//') \ | ||
&& curl -sL -o nginx-${NGINX_VERSION}.tar.gz http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ | ||
&& tar -xf nginx-${NGINX_VERSION}.tar.gz \ | ||
&& cd nginx-${NGINX_VERSION} \ | ||
&& ./configure $(nginx -V 2>&1 | tail -1 | sed -e 's/configure arguments://' -e 's| --add-dynamic-module=[^ ]*||g') --with-ld-opt="-Wl,-rpath,${PHP_LIB}" --add-dynamic-module=../third_party/ngx_devel_kit --add-dynamic-module=.. \ | ||
&& make \ | ||
&& mkdir -p /usr/lib/nginx/modules \ | ||
&& cp objs/ndk_http_module.so /usr/lib/nginx/modules \ | ||
&& cp objs/ngx_http_php_module.so /usr/lib/nginx/modules | ||
# Nginx PHP Module Stable Version | ||
ARG MODULE_CHECKSUM=9fe0ee2ca753cf82b8d982fef1e9888b1a59d8b1 | ||
ARG MODULE_VERSION=0.0.26 | ||
ARG MODULE_NAME=ngx-php | ||
ARG MODULE_SOURCE=https://github.com/rryqszq4/ngx-php | ||
RUN curl -L "${MODULE_SOURCE}/archive/refs/tags/v${MODULE_VERSION}.zip" -o "v${MODULE_VERSION}.zip" && \ | ||
echo "${MODULE_CHECKSUM} v${MODULE_VERSION}.zip" | shasum -c && \ | ||
unzip "v${MODULE_VERSION}.zip" && \ | ||
mv "$MODULE_NAME-$MODULE_VERSION" "$MODULE_NAME" | ||
|
||
# Build with Nginx | ||
RUN cd /usr/src/nginx && \ | ||
CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ | ||
CONFARGS=${CONFARGS/-Os -fomit-frame-pointer -g/-Os} && \ | ||
echo $CONFARGS && \ | ||
./configure --with-compat $CONFARGS --with-ld-opt="-Wl,-rpath,${PHP_LIB}" --add-dynamic-module=../${DEVEL_KIT_NAME} --add-dynamic-module=../${MODULE_NAME} && \ | ||
make modules | ||
|
||
FROM nginx:stable-alpine | ||
# Generate Ngx-PHP configuration demo | ||
RUN apk add bash | ||
SHELL ["/bin/bash", "-c"] | ||
RUN echo $' \n\ | ||
load_module modules/ndk_http_module.so; \n\ | ||
load_module modules/ngx_http_php_module.so; \n\ | ||
events { worker_connections 1024; } \n\ | ||
http { \n\ | ||
include /etc/nginx/mime.types; \n\ | ||
php_ini_path /etc/php8/php.ini; \n\ | ||
gzip on; \n\ | ||
server { \n\ | ||
listen 80; \n\ | ||
server_name localhost; \n\ | ||
location = / { \n\ | ||
content_by_php_block { \n\ | ||
echo "hello world via ngx_php"; \n\ | ||
} \n\ | ||
} \n\ | ||
} \n\ | ||
} \n\ | ||
'> /nginx.conf | ||
|
||
RUN apk --no-cache add php7-embed \ | ||
&& sed -i "s|events {|include /etc/nginx/modules/\*.conf;\n\nevents {|" /etc/nginx/nginx.conf \ | ||
&& echo -e "load_module \"/usr/lib/nginx/modules/ndk_http_module.so\";\nload_module \"/usr/lib/nginx/modules/ngx_http_php_module.so\";" > /etc/nginx/modules/php.conf | ||
|
||
COPY --from=ngx-php /usr/lib/nginx/modules/ /usr/lib/nginx/modules/ | ||
# Build Final Nginx Docker Image | ||
FROM nginx:1.23.1-alpine | ||
LABEL [email protected] | ||
COPY --from=Builder /usr/lib/libphp.so /usr/lib/ | ||
COPY --from=Builder /usr/lib/libargon2.so.1 /usr/lib/ | ||
COPY --from=Builder /lib/libz.so.1 /lib/ | ||
COPY --from=Builder /etc/php8/php.ini /etc/php8/ | ||
COPY --from=Builder /nginx.conf /etc/nginx/nginx.conf | ||
COPY --from=Builder /usr/src/nginx/objs/ndk_http_module.so /etc/nginx/modules/ | ||
COPY --from=Builder /usr/src/nginx/objs/ngx_http_php_module.so /etc/nginx/modules/ | ||
ENV PHP_LIB=/usr/lib |
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,29 @@ | ||
FROM nginx:stable-alpine as ngx-php | ||
|
||
COPY config /build/config | ||
COPY src /build/src | ||
COPY third_party /build/third_party | ||
|
||
ENV PHP_LIB=/usr/lib | ||
|
||
WORKDIR /build | ||
|
||
RUN apk --no-cache add curl gcc g++ make musl-dev linux-headers gd-dev geoip-dev libxml2-dev libxslt-dev openssl-dev paxmark pcre-dev perl-dev pkgconf zlib-dev libedit-dev ncurses-dev php7-dev php7-embed argon2-dev \ | ||
&& NGINX_VERSION=$(nginx -v 2>&1 | sed 's/^[^0-9]*//') \ | ||
&& curl -sL -o nginx-${NGINX_VERSION}.tar.gz http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ | ||
&& tar -xf nginx-${NGINX_VERSION}.tar.gz \ | ||
&& cd nginx-${NGINX_VERSION} \ | ||
&& ./configure $(nginx -V 2>&1 | tail -1 | sed -e 's/configure arguments://' -e 's| --add-dynamic-module=[^ ]*||g') --with-ld-opt="-Wl,-rpath,${PHP_LIB}" --add-dynamic-module=../third_party/ngx_devel_kit --add-dynamic-module=.. \ | ||
&& make \ | ||
&& mkdir -p /usr/lib/nginx/modules \ | ||
&& cp objs/ndk_http_module.so /usr/lib/nginx/modules \ | ||
&& cp objs/ngx_http_php_module.so /usr/lib/nginx/modules | ||
|
||
|
||
FROM nginx:stable-alpine | ||
|
||
RUN apk --no-cache add php7-embed \ | ||
&& sed -i "s|events {|include /etc/nginx/modules/\*.conf;\n\nevents {|" /etc/nginx/nginx.conf \ | ||
&& echo -e "load_module \"/usr/lib/nginx/modules/ndk_http_module.so\";\nload_module \"/usr/lib/nginx/modules/ngx_http_php_module.so\";" > /etc/nginx/modules/php.conf | ||
|
||
COPY --from=ngx-php /usr/lib/nginx/modules/ /usr/lib/nginx/modules/ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, try to use official docker images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soulteary I think joanhey is right. haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this change, and will update this PR once I've finished a piece of content with a better scene, hopefully within the last two months of this year.
eg: https://www.zhihu.com/question/21483073/answer/2647942304
@rryqszq4 @joanhey