Skip to content

Commit

Permalink
Added new way to install brotli
Browse files Browse the repository at this point in the history
Housekeeping
Updated corporate message
Added things to Makefile
  • Loading branch information
Marvin Heilemann committed Jan 16, 2020
1 parent 5fd3a1a commit 7ffa6d3
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 174 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ stop:
start:
docker-compose start

logs:
docker logs marvin-nginx

restart: restart-nginx
# docker-compose restart marvin-xxxx

Expand All @@ -31,9 +34,14 @@ newcert:
# Setup

create-env:
cp .env.development .env.production
if test -f .env.production; \
then echo Production environment file already exist, exiting...; exit 0; \
else cp .env.development .env.production; echo Created production environment file; \
fi

create-reports-dir:
create-dirs:
mkdir -p reports
mkdir -p docker/nginx/certs

setup: create-env create-reports-dir
setup: create-env create-dirs
@echo Success!
9 changes: 5 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
- [ ] Everything pushed to development -> dev.marvin.digital
- [x] replace React with [Preact][1] (check if it works when finished)
- [x] add version to GraphQL data not as file...
- [ ] remove "build brotli from source" with a already finished build
- [ ] always use latest NGINX image
- [ ] test prod build locally with SSL and brotli compression
- [ ] test prod builds Node env
- [x] remove "build brotli from source" with a already finished build
- [x] always use latest NGINX image
- [x] test prod build locally with SSL and brotli compression
- [ ] fix issue with node env version in prod build
- [ ] fix issue with header on prod build
- [ ] new image for start: me while coding
- [ ] new image for start: me while writing
- [ ] MDX pages are not using remark images plugin
Expand Down
111 changes: 55 additions & 56 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,78 +1,95 @@
ARG timezone=Europe/Berlin
ARG version

# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
ARG build_dir="/usr/share/tmp"
ARG modules_dir="/usr/lib/nginx/modules"

# ----------------------------
# Install brotli from source
# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------

FROM nginx:${version} AS builder
FROM debian:latest AS builder

ARG version
ARG build_dir
ARG modules_dir

ENV build_deps "ca-certificates wget git build-essential libpcre3-dev zlib1g-dev"

ENV build_deps "build-essential wget git apt-transport-https ca-certificates"
# ----------------------------
# Install packages

RUN printf "\n\e[96m>\e[0m\033[1m Install packages \e[0m\n\n" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $build_deps \
&& echo "---"

RUN printf "\n\e[96m>\e[0m\033[1m Configure system \e[0m\n\n" \
&& mkdir /root/temp && cd /root/temp \
# ----------------------------
# Setup system

RUN printf "\n\e[96m>\e[0m\033[1m Setup system \e[0m\n\n" \
&& mkdir -p ${build_dir} \
&& mkdir -p ${modules_dir} \
&& echo "---"

RUN printf "\n\e[96m>\e[0m\033[1m Download build module \e[0m\n\n" \
&& cd /root/temp \
&& wget https://hg.nginx.org/pkg-oss/raw-file/tip/build_module.sh \
# remove sudo from file because we are sudo
&& sed -i -e '152,158d' -e 's/sudo //' ./build_module.sh \
# ----------------------------
# Download NGINX

RUN printf "\n\e[96m>\e[0m\033[1m Download NGINX \e[0m\n\n" \
&& cd ${build_dir} \
&& wget https://nginx.org/download/nginx-${version}.tar.gz \
&& tar zxf nginx-${version}.tar.gz \
&& rm nginx-${version}.tar.gz \
&& echo "---"

# ----------------------------
# Download brotli

RUN printf "\n\e[96m>\e[0m\033[1m Download brotli \e[0m\n\n" \
&& cd /root/temp \
&& git clone https://github.com/google/ngx_brotli.git \
&& cd ngx_brotli \
&& git submodule update --init --recursive \
&& cd ${build_dir} \
&& git clone --recursive https://github.com/google/ngx_brotli.git \
&& echo "---"

RUN printf "\n\e[96m>\e[0m\033[1m Build brotli \e[0m\n\n" \
&& cd /root/temp \
&& sh ./build_module.sh -y -f -v ${version} ./ngx_brotli \
&& pkg=$(find /root/debuild/nginx-${version}/debian/debuild-module-brotli -type f -name "nginx-module-brotli_*.deb" -print) \
&& dpkg -i ${pkg} \
# ----------------------------
# Install NGINX with brotli module

RUN printf "\n\e[96m>\e[0m\033[1m Install NGINX with brotli module \e[0m\n\n" \
&& cd ${build_dir}/nginx-${version} \
&& ./configure --with-compat $(cat build_args.txt) --add-dynamic-module=../ngx_brotli \
&& make install \
&& echo "---"

# ----------------------------
# Move compiled modules

# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
RUN printf "\n\e[96m>\e[0m\033[1m Move compiled modules \e[0m\n\n" \
&& cd ${build_dir}/nginx-${version} \
&& cp objs/ngx_http_brotli_filter_module.so ${modules_dir} \
&& chmod 644 ${modules_dir}/ngx_http_brotli_filter_module.so \
&& cp objs/ngx_http_brotli_static_module.so ${modules_dir} \
&& chmod 644 ${modules_dir}/ngx_http_brotli_static_module.so \
&& echo "---"


# ----------------------------
# NGINX
# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------

FROM nginx:${version}

ARG timezone
ARG version
ARG modules_dir

COPY --from=builder /usr/lib/nginx/modules/* /usr/lib/nginx/modules/

COPY share/entrypoint.sh /usr/share/
COPY share/nginx-*.sh /usr/share/
COPY --from=builder ${modules_dir}/* ${modules_dir}/

COPY share/* /usr/share/
COPY conf.d/ /etc/nginx/conf.d/
COPY components/ /etc/nginx/components/
COPY nginx.conf /etc/nginx/nginx.conf
COPY certs/* /etc/nginx/ssl/


# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# Install packages

ENV build_deps ""

RUN printf "\n\e[96m>\e[0m\033[1m Install packages \e[0m\n\n" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $build_deps \
&& echo "---"

# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Configure System

RUN printf "\n\e[96m>\e[0m\033[1m Configure System \e[0m\n\n" \
Expand All @@ -82,24 +99,6 @@ RUN printf "\n\e[96m>\e[0m\033[1m Configure System \e[0m\n\n" \
&& chmod +x /usr/share/nginx-*.sh \
&& echo "---"

# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# Configure NGINX

RUN printf "\n\e[96m>\e[0m\033[1m Configure NGINX \e[0m\n\n" \
&& touch /var/run/nginx.pid \
&& chown -R 991:991 /var/run/nginx.pid \
&& echo "---"

# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# Cleaning

RUN printf "\n\e[96m>\e[0m\033[1m Cleaning \e[0m\n\n" \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge -y $build_deps \
&& apt-get autoremove -y \
&& apt-get clean \
&& echo "---"


ENTRYPOINT ["/usr/share/entrypoint.sh"]

Expand Down
98 changes: 0 additions & 98 deletions docker/nginx/agent.conf

This file was deleted.

2 changes: 1 addition & 1 deletion docker/nginx/components/locations.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Locations

# favicon.ico
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/components/security.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Security

add_header X-Frame-Options "SAMEORIGIN" always;
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/components/ssl.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# SSL

ssl_certificate /etc/nginx/ssl/server.crt;
Expand Down
4 changes: 2 additions & 2 deletions docker/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ server {

include /etc/nginx/components/ssl.conf;

return 301 https://$server_name$request_uri;
return 301 https://marvin.lcl$request_uri;
}

# HTTP, subdomains redirect
Expand All @@ -32,5 +32,5 @@ server {

server_name .marvin.lcl;

return 301 https://$server_name$request_uri;
return 301 https://marvin.lcl$request_uri;
}
6 changes: 3 additions & 3 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ http {
error_log /dev/stderr warn;


# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Small DDoS Protection

limit_conn_zone $binary_remote_addr zone=limit_per_ip:10m;
Expand Down Expand Up @@ -53,7 +53,7 @@ http {
send_timeout 2;


# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Compression

# gzip
Expand Down Expand Up @@ -100,7 +100,7 @@ http {
image/svg+xml;


# ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
# ----------------------------
# Servers

include /etc/nginx/conf.d/*.conf;
Expand Down
1 change: 1 addition & 0 deletions docker/nginx/share/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh

set -eu

mkdir -p \
Expand Down
8 changes: 4 additions & 4 deletions gatsby/browser/corporateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ module.exports = () => {
`

console.log(
`%cMarvin/Design`,
`%cv${process.env.GATSBY_APP_VERSION}`,
`%cMarvin/Design%cv${process.env.GATSBY_APP_VERSION}`,
styleName,
styleVersion
)
console.log(
`%c
Welcome fellow %cdeveloper%c! 🎉
I'm happy to see you here. If you want to have look on my code
and the architecture, my portfolio is available on GitHub:
I'm happy to see you here. If you want to have
look on my code and the architecture, my
portfolio is available on GitHub:
https://github.com/muuvmuuv/portfolio 🔒
`,
styleShared,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "marvin-digital",
"version": "3.3.0",
"version": "3.4.0",
"private": true,
"description": "Portfolio of Marvin Heilemann (@muuvmuuv)",
"repository": {
Expand Down

0 comments on commit 7ffa6d3

Please sign in to comment.