Skip to content

Commit f6a22bc

Browse files
committed
inital
1 parent 774087c commit f6a22bc

File tree

7 files changed

+139
-2
lines changed

7 files changed

+139
-2
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Nginx with Docker
3+
Copyright (c) 2021 Nginx with Docker, soulteary
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# docker-nginx-playground
1+
# Nginx Docker Playground
2+
23
Nginx Development Environment based on official docker image.

make-base.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
RELEASE_DIR="./src";
4+
REPO_NAME="soulteary/prebuilt-nginx-modules"
5+
6+
set -a
7+
. "$RELEASE_DIR/.env"
8+
set +a
9+
10+
# Build For Alpine
11+
12+
TAG=base-$NGINX_VERSION-alpine;
13+
DIST=$REPO_NAME:$TAG
14+
15+
echo "Build: $DIST";
16+
17+
echo $NGINX_VERSION:$NGINX_SHASUM
18+
echo "docker build --build-arg NGINX_VERSION=$NGINX_VERSION --build-arg NGINX_SHASUM=$NGINX_SHASUM --tag $DIST -f "$RELEASE_DIR/Dockerfile.alpine" ."
19+
docker build --build-arg NGINX_VERSION="$NGINX_VERSION" --build-arg NGINX_SHASUM="$NGINX_SHASUM" --tag $DIST -f "$RELEASE_DIR/Dockerfile.alpine" .
20+
21+
# Build For Debian
22+
23+
TAG=base-$NGINX_VERSION;
24+
DIST=$REPO_NAME:$TAG
25+
26+
echo "Build: $DIST";
27+
28+
echo $NGINX_VERSION:$NGINX_SHASUM
29+
echo "docker build --build-arg NGINX_VERSION=$NGINX_VERSION --build-arg NGINX_SHASUM=$NGINX_SHASUM --tag $DIST -f "$RELEASE_DIR/Dockerfile.debian" ."
30+
docker build --build-arg NGINX_VERSION="$NGINX_VERSION" --build-arg NGINX_SHASUM="$NGINX_SHASUM" --tag $DIST -f "$RELEASE_DIR/Dockerfile.debian" .

push-image.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
REPO_NAME="soulteary/prebuilt-nginx-modules"
4+
RELEASE_DIR="./src";
5+
6+
set -a
7+
. "$RELEASE_DIR/.env"
8+
set +a
9+
10+
TAG="base-$NGINX_VERSION-alpine";
11+
DIST="$REPO_NAME:$TAG"
12+
13+
if [[ "$(docker images -q $DIST 2> /dev/null)" != "" ]]; then
14+
echo "Push: $DIST";
15+
docker push $DIST;
16+
fi
17+
18+
RELEASE_DIR="./modules";
19+
20+
for moduleName in $RELEASE_DIR/*; do
21+
set -a
22+
. "$moduleName/.env"
23+
set +a
24+
25+
tag=$(echo $moduleName | cut -b 11-);
26+
27+
if [ -f "$moduleName/Dockerfile.alpine" ]; then
28+
BUILD_NAME="$REPO_NAME:$tag-$NGINX_VERSION-alpine"
29+
if [[ "$(docker images -q $BUILD_NAME 2> /dev/null)" != "" ]]; then
30+
echo "Push: $BUILD_NAME";
31+
docker push $BUILD_NAME;
32+
fi
33+
fi
34+
35+
if [ -f "$moduleName/Dockerfile.debian" ]; then
36+
BUILD_NAME="$REPO_NAME:$tag-$NGINX_VERSION"
37+
if [[ "$(docker images -q $BUILD_NAME 2> /dev/null)" != "" ]]; then
38+
echo "Push: $BUILD_NAME";
39+
docker push $BUILD_NAME;
40+
fi
41+
fi
42+
43+
done

src/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NGINX_VERSION=1.21.0
2+
NGINX_SHASUM=40776903508b610e3c6dc9feaa8408d47074accc

src/Dockerfile.alpine

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG NGINX_VERSION=1.19.7
2+
FROM nginx:${NGINX_VERSION}-alpine
3+
# Mirror
4+
# RUN cat /etc/apk/repositories | sed -e "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/" | tee /etc/apk/repositories
5+
6+
ARG NGINX_SHASUM=0dde53b5a948efc9dc852814186052e559d190ea
7+
RUN apk add --no-cache --virtual .build-deps gcc libc-dev make openssl-dev pcre-dev zlib-dev linux-headers libxslt-dev gd-dev geoip-dev perl-dev libedit-dev mercurial bash alpine-sdk findutils && \
8+
mkdir -p /usr/src && cd /usr/src && \
9+
curl -L "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx.tar.gz && \
10+
echo "$NGINX_SHASUM nginx.tar.gz" | shasum -c && \
11+
tar -zxC /usr/src -f nginx.tar.gz && \
12+
cd /usr/src && \
13+
mv /usr/src/nginx-$NGINX_VERSION /usr/src/nginx && \
14+
CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \
15+
CONFARGS=${CONFARGS/-Os -fomit-frame-pointer -g/-Os} && \
16+
export CONFARGS=$CONFARGS;

src/Dockerfile.debian

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources
2+
3+
ARG NGINX_VERSION=1.19.7
4+
FROM nginx:${NGINX_VERSION}
5+
# Mirror
6+
# RUN sed -i 's/http:\/\/.*.debian.org/http:\/\/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list
7+
8+
ARG NGINX_SHASUM=0dde53b5a948efc9dc852814186052e559d190ea
9+
10+
RUN sed -i '/deb http:\/\/nginx.org\/packages\/debian\/ stretch nginx/d' /etc/apt/sources.list && \
11+
sed -i '/deb http:\/\/mirrors.tuna.tsinghua.edu.cn stretch\/updates main/d' /etc/apt/sources.list && \
12+
apt-get update && \
13+
apt-get install -y apt-transport-https lsb-release ca-certificates && \
14+
apt-get install -y build-essential software-properties-common && \
15+
apt install -y perl libperl-dev libgd3 libgd-dev libgeoip1 libgeoip-dev geoip-bin libxml2 libxml2-dev libxslt1.1 libxslt1-dev libc6-dev libpcre3-dev&& \
16+
apt install -y wget curl && mkdir -p /usr/src
17+
18+
RUN cd /usr/src && \
19+
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz && \
20+
tar zxvf pcre-8.44.tar.gz && \
21+
cd pcre-8.44 && \
22+
./configure && make && make install
23+
24+
RUN cd /usr/src && \
25+
wget https://www.zlib.net/zlib-1.2.11.tar.gz && \
26+
tar zxvf zlib-1.2.11.tar.gz && \
27+
cd zlib-1.2.11 && \
28+
./configure && make && make install
29+
30+
RUN cd /usr/src && \
31+
wget http://www.openssl.org/source/openssl-1.1.1k.tar.gz && \
32+
tar zxvf openssl-1.1.1k.tar.gz && \
33+
cd openssl-1.1.1k && \
34+
./config && make && make install
35+
36+
RUN cd /usr/src && \
37+
curl -L "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx.tar.gz && \
38+
echo "$NGINX_SHASUM nginx.tar.gz" | shasum -c && \
39+
tar -zxC /usr/src -f nginx.tar.gz && \
40+
cd /usr/src && \
41+
mv /usr/src/nginx-$NGINX_VERSION /usr/src/nginx && \
42+
CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p' | sed -n -e 's/--with-cc-opt=.*//p') && \
43+
echo "CONFARGS=\"$CONFARGS\"" >>~/.bashrc && echo "export CONFARGS" >>~/.bashrc
44+
45+
SHELL ["/bin/bash", "-c"]

0 commit comments

Comments
 (0)