Skip to content

Commit 17d7c46

Browse files
committed
Initial commit
0 parents  commit 17d7c46

32 files changed

+1990
-0
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
18+
- uses: actions/checkout@v2
19+
20+
- name: Configure Github Package Registry
21+
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
22+
- name: Install dependencies
23+
run: sudo apt-get install -y wait-for-it
24+
- name: Run tests
25+
run: ./test.sh oss
26+
- name: Push container image
27+
run: docker tag nginx-s3-gateway docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/nginx-oss-s3-gateway
28+

.gitignore

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/intellij
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij
3+
4+
### Intellij ###
5+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7+
8+
# User-specific stuff
9+
.idea/**/workspace.xml
10+
.idea/**/tasks.xml
11+
.idea/**/usage.statistics.xml
12+
.idea/**/dictionaries
13+
.idea/**/shelf
14+
15+
# Generated files
16+
.idea/**/contentModel.xml
17+
18+
# Sensitive or high-churn files
19+
.idea/**/dataSources/
20+
.idea/**/dataSources.ids
21+
.idea/**/dataSources.local.xml
22+
.idea/**/sqlDataSources.xml
23+
.idea/**/dynamic.xml
24+
.idea/**/uiDesigner.xml
25+
.idea/**/dbnavigator.xml
26+
27+
# Gradle
28+
.idea/**/gradle.xml
29+
.idea/**/libraries
30+
31+
# Gradle and Maven with auto-import
32+
# When using Gradle or Maven with auto-import, you should exclude module files,
33+
# since they will be recreated, and may cause churn. Uncomment if using
34+
# auto-import.
35+
# .idea/artifacts
36+
# .idea/compiler.xml
37+
# .idea/jarRepositories.xml
38+
# .idea/modules.xml
39+
# .idea/*.iml
40+
# .idea/modules
41+
# *.iml
42+
# *.ipr
43+
44+
# CMake
45+
cmake-build-*/
46+
47+
# Mongo Explorer plugin
48+
.idea/**/mongoSettings.xml
49+
50+
# File-based project format
51+
*.iws
52+
53+
# IntelliJ
54+
out/
55+
56+
# mpeltonen/sbt-idea plugin
57+
.idea_modules/
58+
59+
# JIRA plugin
60+
atlassian-ide-plugin.xml
61+
62+
# Cursive Clojure plugin
63+
.idea/replstate.xml
64+
65+
# Crashlytics plugin (for Android Studio and IntelliJ)
66+
com_crashlytics_export_strings.xml
67+
crashlytics.properties
68+
crashlytics-build.properties
69+
fabric.properties
70+
71+
# Editor-based Rest Client
72+
.idea/httpRequests
73+
74+
# Android studio 3.1+ serialized cache file
75+
.idea/caches/build_file_checksums.ser
76+
77+
### Intellij Patch ###
78+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
79+
80+
*.iml
81+
modules.xml
82+
.idea/misc.xml
83+
*.ipr
84+
85+
# Sonarlint plugin
86+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
87+
.idea/**/sonarlint/
88+
89+
# SonarQube Plugin
90+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
91+
.idea/**/sonarIssues.xml
92+
93+
# Markdown Navigator plugin
94+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
95+
.idea/**/markdown-navigator.xml
96+
.idea/**/markdown-navigator-enh.xml
97+
.idea/**/markdown-navigator/
98+
99+
# Cache file creation bug
100+
# See https://youtrack.jetbrains.com/issue/JBR-2257
101+
.idea/$CACHE_FILE$
102+
103+
# CodeStream plugin
104+
# https://plugins.jetbrains.com/plugin/12206-codestream
105+
.idea/codestream.xml
106+
107+
# End of https://www.toptal.com/developers/gitignore/api/intellij
108+
109+
# Test data files
110+
test-settings.*
111+
s3-requests.http
112+
httpRequests/

Dockerfile.oss

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM nginx:1.19.2
2+
3+
ENV NGINX_VERSION "1.19.2"
4+
ENV HEADERS_MORE_VERSION "v0.33"
5+
6+
# We modify the nginx base image by:
7+
# 1. Installing the headers-more module
8+
# 2. Adding configuration files needed for proxying private S3 buckets
9+
# 3. Adding a directory for proxied objects to be stored
10+
11+
RUN set -eux \
12+
export DEBIAN_FRONTEND=noninteractive; \
13+
apt-get update -qq; \
14+
apt-get install -y -qq build-essential libpcre3-dev git; \
15+
curl -o /tmp/nginx.tar.gz --retry 6 -Ls "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"; \
16+
mkdir /tmp/nginx /tmp/headers-more; \
17+
tar -C /tmp/nginx --strip-components 1 -xzf /tmp/nginx.tar.gz; \
18+
curl -o /tmp/headers-more.tar.gz --retry 6 -Ls "https://github.com/openresty/headers-more-nginx-module/archive/${HEADERS_MORE_VERSION}.tar.gz"; \
19+
tar -C "/tmp/headers-more" --strip-components 1 -xzf /tmp/headers-more.tar.gz; \
20+
cd /tmp/nginx; \
21+
./configure --add-dynamic-module=/tmp/headers-more \
22+
--without-http_gzip_module \
23+
--prefix=/etc/nginx \
24+
--sbin-path=/usr/sbin/nginx \
25+
--modules-path=/usr/lib/nginx/modules \
26+
--conf-path=/etc/nginx/nginx.conf \
27+
--error-log-path=/var/log/nginx/error.log \
28+
--http-log-path=/var/log/nginx/access.log \
29+
--pid-path=/var/run/nginx.pid \
30+
--lock-path=/var/run/nginx.lock \
31+
--http-client-body-temp-path=/var/cache/nginx/client_temp \
32+
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
33+
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
34+
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
35+
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
36+
--user=nginx --group=nginx --with-compat --with-file-aio \
37+
--with-threads \
38+
--with-cc-opt="-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-${NGINX_VERSION}/debian/debuild-base/nginx-${NGINX_VERSION}=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC" \
39+
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'; \
40+
make -j $(nproc); \
41+
cp /tmp/nginx/objs/ngx_http_headers_more_filter_module.so /usr/lib/nginx/modules; \
42+
apt-get purge -y --auto-remove build-essential libpcre3-dev git; \
43+
rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/*
44+
45+
COPY common/etc /etc
46+
COPY common/docker-entrypoint.d/00-check-for-required-env.sh /docker-entrypoint.d/00-check-for-required-env.sh
47+
COPY oss/etc /etc
48+
49+
RUN set -eux \
50+
export DEBIAN_FRONTEND=noninteractive; \
51+
mkdir -p /var/cache/nginx/s3_proxy; \
52+
chown nginx:nginx /var/cache/nginx/s3_proxy; \
53+
chmod -R +x /docker-entrypoint.d/*

Dockerfile.plus

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM debian:buster-slim
2+
3+
ARG NGINX_GPGKEY
4+
5+
ENV NGINX_VERSION 22
6+
ENV PKG_RELEASE 1~buster
7+
8+
ENV NJS_VERSION 0.4.3
9+
ENV HEADERS_MORE_VERSION 0.33
10+
11+
COPY plus/etc/ssl /etc/ssl
12+
COPY plus/usr /usr
13+
14+
# Copy files from the OSS NGINX Docker container such that the container
15+
# startup is the same.
16+
# Source: https://github.com/nginxinc/docker-nginx/tree/1.19.2/stable/buster
17+
COPY plus/docker-entrypoint.sh /docker-entrypoint.sh
18+
COPY plus/docker-entrypoint.d /docker-entrypoint.d
19+
20+
RUN set -eux \
21+
export DEBIAN_FRONTEND=noninteractive; \
22+
# create nginx user/group first, to be consistent throughout docker variants
23+
addgroup --system --gid 101 nginx; \
24+
adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx; \
25+
apt-get -qq update; \
26+
apt-get -qq upgrade -y; \
27+
sh -a /usr/local/bin/add_nginx_plus_repo.sh; \
28+
rm /usr/local/bin/add_nginx_plus_repo.sh; \
29+
apt-get -qq update; \
30+
apt-get -qq install --no-install-recommends --no-install-suggests -y \
31+
nginx-plus=${NGINX_VERSION}-${PKG_RELEASE} \
32+
nginx-plus-module-headers-more=${NGINX_VERSION}+${HEADERS_MORE_VERSION}-${PKG_RELEASE} \
33+
nginx-plus-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${PKG_RELEASE} \
34+
gettext-base; \
35+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
36+
rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/*; \
37+
# forward request and error logs to docker log collector
38+
ln -sf /dev/stdout /var/log/nginx/access.log; \
39+
ln -sf /dev/stderr /var/log/nginx/error.log; \
40+
chmod -R -v +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh
41+
42+
ENTRYPOINT ["/docker-entrypoint.sh"]
43+
44+
EXPOSE 80
45+
46+
STOPSIGNAL SIGTERM
47+
48+
CMD ["nginx", "-g", "daemon off;"]
49+
50+
# NGINX Docker image setup complete, everything below is specific for
51+
# the S3 Gateway use case.
52+
53+
COPY plus/etc/nginx /etc/nginx
54+
COPY common/etc /etc
55+
COPY common/docker-entrypoint.d/00-check-for-required-env.sh /docker-entrypoint.d/00-check-for-required-env.sh
56+
57+
RUN set -eux \
58+
export DEBIAN_FRONTEND=noninteractive; \
59+
mkdir -p /var/cache/nginx/s3_proxy; \
60+
chown nginx:nginx /var/cache/nginx/s3_proxy; \
61+
chmod -R +x /docker-entrypoint.d/*

0 commit comments

Comments
 (0)