-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,780 changed files
with
1,271,923 additions
and
82 deletions.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
Dockerfile |
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,54 +1,67 @@ | ||
FROM enclaive/gramine-os:latest | ||
FROM enclaive/debug-gramine:latest | ||
|
||
ARG NGX_VERSION=1.18.0 | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y build-essential apache2-utils libssl-dev zlib1g zlib1g-dev | ||
RUN apt-get update &&\ | ||
apt-get install -y build-essential libssl-dev zlib1g zlib1g-dev wget \ | ||
re2c | ||
|
||
# download source | ||
WORKDIR /entrypoint | ||
WORKDIR /src | ||
|
||
ADD https://nginx.org/download/nginx-${NGX_VERSION}.tar.gz ./ | ||
RUN tar -xzf nginx-${NGX_VERSION}.tar.gz | ||
RUN rm nginx-${NGX_VERSION}.tar.gz | ||
#build pcre | ||
RUN wget https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.zip &&\ | ||
unzip pcre-8.45.zip &&\ | ||
cd pcre-8.45 &&\ | ||
./configure --disable-shared --enable-static --prefix /usr &&\ | ||
make -j &&\ | ||
make install | ||
|
||
# add nginx.conf | ||
COPY ./conf /entrypoint/conf | ||
|
||
# add /html | ||
WORKDIR /entrypoint/html | ||
|
||
COPY ./html . | ||
|
||
# build nginx | ||
WORKDIR /entrypoint/nginx-${NGX_VERSION} | ||
|
||
RUN ./configure \ | ||
--prefix=/entrypoint \ | ||
--without-http_rewrite_module \ | ||
--with-http_ssl_module | ||
RUN make | ||
RUN make install | ||
|
||
# generate server.cert | ||
WORKDIR /entrypoint/conf | ||
|
||
COPY ./ssl . | ||
RUN chmod +x cert-gen.sh | ||
RUN ./cert-gen.sh # creates self-signed server certificate if /ssl is empty | ||
|
||
# create manifest | ||
WORKDIR /manifest | ||
|
||
COPY nginx.manifest.template . | ||
RUN /manifest/manifest.sh nginx | ||
|
||
# clean up | ||
RUN rm -rf /entrypoint/nginx-${NGX_VERSION} /entrypoint/conf/ca.* /entrypoint/conf/cert-gen.sh | ||
|
||
# start enclaived nginx | ||
ENTRYPOINT [ "/entrypoint/enclaive.sh" ] | ||
CMD [ "nginx" ] | ||
RUN wget https://nginx.org/download/nginx-${NGX_VERSION}.tar.gz &&\ | ||
tar xvf nginx-${NGX_VERSION}.tar.gz &&\ | ||
rm nginx-${NGX_VERSION}.tar.gz &&\ | ||
cd nginx-* ;\ | ||
./configure \ | ||
--prefix=/app \ | ||
--with-pcre=/src/pcre-8.45 \ | ||
--with-http_ssl_module \ | ||
--with-select_module &&\ | ||
make -j &&\ | ||
make install &&\ | ||
rm -rf nginx-* | ||
|
||
ADD . /app | ||
|
||
# creates self-signed server certificate if /ssl is empty | ||
RUN cd /app/conf && ./cert-gen.sh | ||
|
||
# create nginx manifest | ||
RUN cd /app &&\ | ||
gramine-sgx-gen-private-key &&\ | ||
gramine-manifest \ | ||
-Dlog_level=error \ | ||
-Darch_libdir=/lib/x86_64-linux-gnu \ | ||
nginx.manifest.template nginx.manifest &&\ | ||
gramine-sgx-sign \ | ||
--manifest nginx.manifest \ | ||
--output nginx.manifest.sgx | ||
|
||
COPY fpm.conf /usr/local/etc/php-fpm.conf | ||
|
||
# create php manifest | ||
RUN cd /app &&\ | ||
gramine-manifest \ | ||
-Dlog_level=error \ | ||
-Darch_libdir=/lib/x86_64-linux-gnu \ | ||
php.manifest.template php.manifest &&\ | ||
gramine-sgx-sign \ | ||
--manifest php.manifest \ | ||
--output php.manifest.sgx | ||
|
||
|
||
|
||
ENTRYPOINT ["/app/entrypoint.sh"] | ||
|
||
# ports | ||
EXPOSE 80 443 |
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,4 @@ | ||
docker: .PHONY | ||
docker build . -t enclaive/nginx | ||
|
||
.PHONY: |
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,16 @@ | ||
php isn't built in docker yet because downstream patching architecture has yet to be established | ||
|
||
php requires patching away sockopts in m4, because they're detected as as supported on the linux build host, | ||
when the actual target (gramine) barely has any sockopts | ||
|
||
that is at least SO_LISTENQLEN and TCP_INFO, see | ||
https://github.com/gramineproject/gramine/issues/503 | ||
|
||
also it needs manually linking against the gramine libm instead of host libm because the gramine ld loader implements | ||
symbol versioning without actually following the glibc versions. | ||
|
||
i also patched away all other lib dependencies in AC, but they might actually be fixable, specifically openssl could probably work | ||
|
||
note php-fpm or niginx must not fork, even if it disagrees and recommends more workers. | ||
clone() is implementing in gramine as forking the entire enclave. | ||
|
File renamed without changes.
0
ssl/cert-gen.sh → conf/cert-gen.sh
100644 → 100755
File renamed without changes.
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
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,12 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
|
||
|
||
cd /app | ||
|
||
gramine-sgx-get-token --output php.token --sig php.sig | ||
gramine-sgx php --force-stderr --nodaemonize & | ||
|
||
gramine-sgx-get-token --output nginx.token --sig nginx.sig | ||
gramine-sgx nginx |
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,15 @@ | ||
[global] | ||
pid = /app/logs/php-fpm.pid | ||
error_log = /app/logs/php-fpm.log | ||
|
||
[www] | ||
user = www-data | ||
group = www-data | ||
listen = 127.0.0.1:9000 | ||
listen.owner = www-data | ||
listen.group = www-data | ||
pm = dynamic | ||
pm.max_children = 1 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 1 |
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 @@ | ||
<?php phpinfo(); ?> |
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,17 @@ | ||
<?php | ||
/** | ||
* Front to the WordPress application. This file doesn't do anything, but loads | ||
* wp-blog-header.php which does and tells WordPress to load the theme. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Tells WordPress to load the WordPress theme and output it. | ||
* | ||
* @var bool | ||
*/ | ||
define( 'WP_USE_THEMES', true ); | ||
|
||
/** Loads the WordPress Environment and Template */ | ||
require __DIR__ . '/wp-blog-header.php'; |
Oops, something went wrong.