Skip to content

Commit 3391758

Browse files
authored
feat: multi-stage builds
1 parent d772660 commit 3391758

File tree

6 files changed

+38
-23
lines changed

6 files changed

+38
-23
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.github/
2+
.dockerignore
3+
.editorconfig
4+
LICENSE
5+
README.md

.github/workflows/dockerimage.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ jobs:
2525
2626
- id: checkout
2727
name: Checkout
28-
uses: actions/checkout@v3
29-
30-
- id: login
31-
name: Login to Docker Hub
32-
uses: docker/login-action@v2
33-
if: |
34-
github.ref == 'refs/heads/main'
35-
with:
36-
username: ${{ secrets.DOCKER_USERNAME }}
37-
password: ${{ secrets.DOCKER_PASSWORD }}
28+
uses: actions/checkout@v4
3829

3930
- id: build
4031
name: Build image
@@ -48,10 +39,19 @@ jobs:
4839
docker volume create usr-share-geoip
4940
docker run --rm --name geoipupdate -v usr-share-geoip:/usr/share/GeoIP -e GEOIPUPDATE_FREQUENCY=0 -e GEOIPUPDATE_ACCOUNT_ID='${{ secrets.GEOIPUPDATE_ACCOUNT_ID }}' -e GEOIPUPDATE_LICENSE_KEY='${{ secrets.GEOIPUPDATE_LICENSE_KEY }}' -e GEOIPUPDATE_EDITION_IDS='GeoLite2-City GeoLite2-Country' maxmindinc/geoipupdate
5041
docker run --rm --name nginx gokaygurcan/nginx nginx -V
42+
43+
- id: login
44+
name: Login to Docker Hub
45+
uses: docker/login-action@v3
46+
if: |
47+
github.ref == 'refs/heads/main'
48+
with:
49+
username: ${{ secrets.DOCKER_USERNAME }}
50+
password: ${{ secrets.DOCKER_PASSWORD }}
5151

5252
- id: push
5353
name: Push to Docker Registry
54-
uses: docker/build-push-action@v3
54+
uses: docker/build-push-action@v6
5555
if: |
5656
github.ref == 'refs/heads/main'
5757
with:

Dockerfile

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# gokaygurcan/dockerfile-nginx
22

3-
FROM gokaygurcan/ubuntu:latest
4-
5-
# metadata
3+
FROM gokaygurcan/ubuntu:latest as build-nginx
64
LABEL maintainer "Gökay Gürcan <[email protected]>"
75

86
ARG DEBIAN_FRONTEND=noninteractive
97
ENV USR_SRC=/usr/src \
108
USR_SRC_NGINX=/usr/src/nginx \
119
USR_SRC_NGINX_MODS=/usr/src/nginx/modules \
12-
NGINX_VERSION=1.27.0 \
10+
NGINX_VERSION=1.27.1 \
1311
OPENSSL_VERSION=3.3.1 \
14-
LIBMAXMINDDB_VERSION=1.10.0
12+
LIBMAXMINDDB_VERSION=1.11.0
1513

1614
USER root
1715

@@ -98,6 +96,7 @@ RUN set -ex && \
9896
mv eustas-ngx_brotli-* brotli && \
9997
cd ${USR_SRC_NGINX_MODS}/brotli/deps && \
10098
rm -rf ./brotli && \
99+
# google/brotli
101100
aria2c -q https://github.com/google/brotli/tarball/master && \
102101
tar -xzf google-brotli-*.tar.gz && \
103102
rm google-brotli-*.tar.gz && \
@@ -107,10 +106,9 @@ RUN set -ex && \
107106
aria2c -q https://github.com/aperezdc/ngx-fancyindex/tarball/master && \
108107
tar -xzf aperezdc-ngx-fancyindex-*.tar.gz && \
109108
rm aperezdc-ngx-fancyindex-*.tar.gz && \
110-
mv aperezdc-ngx-fancyindex-* fancyindex
111-
109+
mv aperezdc-ngx-fancyindex-* fancyindex && \
112110
# compile nginx
113-
RUN cd ${USR_SRC_NGINX} && \
111+
cd ${USR_SRC_NGINX} && \
114112
sh ./configure \
115113
--conf-path=/etc/nginx/nginx.conf \
116114
--sbin-path=/usr/sbin/nginx \
@@ -159,6 +157,8 @@ RUN cd ${USR_SRC_NGINX} && \
159157
make && \
160158
make install && \
161159
echo "✓" | tee /usr/local/nginx/html/index.html && \
160+
# Diffie-Hellman
161+
openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096 && \
162162
# clean up
163163
rm /etc/nginx/*.default && \
164164
apt-get autoclean -yqq && \
@@ -171,13 +171,21 @@ RUN cd ${USR_SRC_NGINX} && \
171171
ln -sf /dev/stdout /var/log/nginx/access.log && \
172172
ln -sf /dev/stderr /var/log/nginx/error.log
173173

174+
# FROM ubuntu:noble
175+
FROM gokaygurcan/ubuntu:latest
176+
LABEL maintainer "Gökay Gürcan <[email protected]>"
177+
178+
COPY --from=build-nginx /etc/nginx /etc/nginx
179+
COPY --from=build-nginx /usr/local/nginx /usr/local/nginx
180+
COPY --from=build-nginx /var/log/nginx /var/log/nginx
181+
COPY --from=build-nginx /usr/sbin/nginx /usr/sbin/nginx
182+
174183
WORKDIR /etc/nginx
175184

176185
# copy configs from docker folder
177186
COPY docker /
178187

179-
# Diffie-Hellman
180-
RUN openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096
188+
ENV PATH "${PATH}:/usr/sbin/nginx"
181189

182190
EXPOSE 80/tcp 443/tcp
183191

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
| Variable | Version |
1212
| -------------------- | ---------------------- |
13-
| NGINX_VERSION | 1.27.0 |
13+
| NGINX_VERSION | 1.27.1 |
1414
| OPENSSL_VERSION | 3.3.1 |
15-
| LIBMAXMINDDB_VERSION | 1.10.0 |
15+
| LIBMAXMINDDB_VERSION | 1.11.0 |
1616

1717
## Additional packages
1818

Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
more_set_headers "Server: Unknown";
2+
more_set_headers "X-Powered-By: gokaygurcan/nginx";

docker/etc/nginx/nginx.conf

+1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ http {
5757

5858
# include configs
5959
include /etc/nginx/conf.d/*.conf;
60+
# include /etc/nginx/conf.optional.d/*.conf;
6061
include /etc/nginx/sites-enabled/**/*;
6162
}

0 commit comments

Comments
 (0)