-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
178 additions
and
6 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,50 @@ | ||
# base image | ||
FROM --platform=amd64 rust:slim-bookworm AS builder | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y gcc g++ libc6-dev pkg-config libssl-dev | ||
|
||
WORKDIR /src | ||
COPY src ./src | ||
COPY Cargo.toml Cargo.lock ./ | ||
RUN cargo build --release --locked -p ic_tee_nitro_gateway | ||
|
||
FROM debian:bookworm-slim AS runtime | ||
|
||
# install dependency tools | ||
RUN apt-get update \ | ||
&& apt-get install -y net-tools iptables iproute2 wget ca-certificates tzdata curl openssl \ | ||
&& update-ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# working directory | ||
WORKDIR /app | ||
|
||
# supervisord to manage programs | ||
RUN wget -O supervisord http://public.artifacts.marlin.pro/projects/enclaves/supervisord_master_linux_amd64 | ||
RUN chmod +x supervisord | ||
|
||
# transparent proxy component inside the enclave to enable outgoing connections | ||
RUN wget -O ip-to-vsock-transparent http://public.artifacts.marlin.pro/projects/enclaves/ip-to-vsock-transparent_v1.0.0_linux_amd64 | ||
RUN chmod +x ip-to-vsock-transparent | ||
|
||
# proxy to expose attestation server outside the enclave | ||
RUN wget -O vsock-to-ip http://public.artifacts.marlin.pro/projects/enclaves/vsock-to-ip_v1.0.0_linux_amd64 | ||
RUN chmod +x vsock-to-ip | ||
|
||
# dnsproxy to provide DNS services inside the enclave | ||
RUN wget -O dnsproxy http://public.artifacts.marlin.pro/projects/enclaves/dnsproxy_v0.72.0_linux_amd64 | ||
RUN chmod +x dnsproxy | ||
|
||
# supervisord config | ||
COPY nitro_enclave/supervisord.conf /etc/supervisord.conf | ||
|
||
# setup.sh script that will act as entrypoint | ||
COPY nitro_enclave/setup.sh ./ | ||
RUN chmod +x setup.sh | ||
|
||
# your custom setup goes here | ||
COPY --from=builder /src/target/release/ic_tee_nitro_gateway ./ic_tee_nitro_gateway | ||
|
||
# entry point | ||
ENTRYPOINT [ "/app/setup.sh" ] |
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,50 @@ | ||
# base image | ||
FROM --platform=arm64 rust:slim-bookworm AS builder | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y gcc g++ libc6-dev pkg-config libssl-dev | ||
|
||
WORKDIR /src | ||
COPY src ./src | ||
COPY Cargo.toml Cargo.lock ./ | ||
RUN cargo build --release --locked -p ic_tee_nitro_gateway | ||
|
||
FROM debian:bookworm-slim AS runtime | ||
|
||
# install dependency tools | ||
RUN apt-get update \ | ||
&& apt-get install -y net-tools iptables iproute2 wget ca-certificates tzdata curl openssl \ | ||
&& update-ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# working directory | ||
WORKDIR /app | ||
|
||
# supervisord to manage programs | ||
RUN wget -O supervisord http://public.artifacts.marlin.pro/projects/enclaves/supervisord_master_linux_arm64 | ||
RUN chmod +x supervisord | ||
|
||
# transparent proxy component inside the enclave to enable outgoing connections | ||
RUN wget -O ip-to-vsock-transparent http://public.artifacts.marlin.pro/projects/enclaves/ip-to-vsock-transparent_v1.0.0_linux_arm64 | ||
RUN chmod +x ip-to-vsock-transparent | ||
|
||
# proxy to expose attestation server outside the enclave | ||
RUN wget -O vsock-to-ip http://public.artifacts.marlin.pro/projects/enclaves/vsock-to-ip_v1.0.0_linux_arm64 | ||
RUN chmod +x vsock-to-ip | ||
|
||
# dnsproxy to provide DNS services inside the enclave | ||
RUN wget -O dnsproxy http://public.artifacts.marlin.pro/projects/enclaves/dnsproxy_v0.72.0_linux_arm64 | ||
RUN chmod +x dnsproxy | ||
|
||
# supervisord config | ||
COPY nitro_enclave/supervisord.conf /etc/supervisord.conf | ||
|
||
# setup.sh script that will act as entrypoint | ||
COPY nitro_enclave/setup.sh ./ | ||
RUN chmod +x setup.sh | ||
|
||
# your custom setup goes here | ||
COPY --from=builder /src/target/release/ic_tee_nitro_gateway ./ic_tee_nitro_gateway | ||
|
||
# entry point | ||
ENTRYPOINT [ "/app/setup.sh" ] |
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,28 @@ | ||
#!/bin/sh | ||
|
||
# setting an address for loopback | ||
ifconfig lo 127.0.0.1 | ||
ifconfig | ||
|
||
# Debian: failed to initialize nft: Protocol not supported | ||
update-alternatives --set iptables /usr/sbin/iptables-legacy | ||
# update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy | ||
# update-alternatives --set arptables /usr/sbin/arptables-legacy | ||
# update-alternatives --set ebtables /usr/sbin/ebtables-legacy | ||
|
||
# adding a default route | ||
ip route add default via 127.0.0.1 dev lo | ||
route -n | ||
|
||
# iptables rules to route traffic to transparent proxy | ||
iptables -A OUTPUT -t nat -p tcp --dport 1:65535 ! -d 127.0.0.1 -j DNAT --to-destination 127.0.0.1:1200 | ||
# replace the source address with 127.0.0.1 for outgoing packets with a source of 0.0.0.0 | ||
# ensures returning packets have 127.0.0.1 as the destination and not 0.0.0.0 | ||
iptables -t nat -A POSTROUTING -o lo -s 0.0.0.0 -j SNAT --to-source 127.0.0.1 | ||
iptables -L -t nat -v -n | ||
|
||
# your custom setup goes here | ||
|
||
# starting supervisord | ||
cat /etc/supervisord.conf | ||
/app/supervisord |
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,47 @@ | ||
[supervisord] | ||
loglevel=debug | ||
logfile=/dev/stdout | ||
logfile_maxbytes=0 | ||
|
||
# transparent proxy component inside enclave | ||
[program:ip-to-vsock-transparent] | ||
command=/app/ip-to-vsock-transparent --vsock-addr 3:1200 --ip-addr 127.0.0.1:1200 | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stdout | ||
stderr_logfile_maxbytes=0 | ||
|
||
# DNS-over-HTTPS provider | ||
[program:dnsproxy] | ||
command=/app/dnsproxy -u https://1.1.1.1/dns-query -v | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stdout | ||
stderr_logfile_maxbytes=0 | ||
|
||
[program:ic_tee_nitro_gateway-local] | ||
command=/app/vsock-to-ip --vsock-addr 88:8080 --ip-addr 127.0.0.1:8080 | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stdout | ||
stderr_logfile_maxbytes=0 | ||
|
||
[program:ic_tee_nitro_gateway-public] | ||
command=/app/vsock-to-ip --vsock-addr 88:443 --ip-addr 127.0.0.1:8443 | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stdout | ||
stderr_logfile_maxbytes=0 | ||
|
||
# your custom programs go here | ||
[program:ic_tee_nitro_gateway] | ||
command=/app/ic_tee_nitro_gateway --authentication-canister e7tgb-6aaaa-aaaap-akqfa-cai --id-scope image --session-expires-in-ms 86400000 --configuration-canister 53cyg-yyaaa-aaaap-ahpua-cai --configuration-namespace _ --configuration-upgrade-identity fbi6t-ogdrt-s4de4-sxive-x4yid-xfrk2-e6jgf-jbnuh-rzxoj-qv2qa-zae | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stdout | ||
stderr_logfile_maxbytes=0 |
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