diff options
| author | Paul Buetow <paul@buetow.org> | 2026-01-29 08:33:13 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-01-29 08:33:13 +0200 |
| commit | 683fc17608f4779e71aafb8fbabc42964fd8b936 (patch) | |
| tree | 502b7f980978c5b160b85f4e45a9e4f177715211 | |
| parent | e43ba46b7d4e4f0796f94a5394d6a9fdf609482b (diff) | |
Add Docker image for f3s deployment
Amp-Thread-ID: https://ampcode.com/threads/T-019c086d-c760-779d-b740-0f748094b62a
Co-authored-by: Amp <amp@ampcode.com>
| -rw-r--r-- | docker-image/Dockerfile | 30 | ||||
| -rw-r--r-- | docker-image/Justfile | 21 | ||||
| -rw-r--r-- | docker-image/index.pl | 80 |
3 files changed, 131 insertions, 0 deletions
diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile new file mode 100644 index 0000000..736f25e --- /dev/null +++ b/docker-image/Dockerfile @@ -0,0 +1,30 @@ +FROM httpd:2.4-alpine + +RUN apk update && apk add --no-cache \ + perl \ + bind-tools \ + && rm -rf /var/cache/apk/* + +# Enable CGI module +RUN sed -i 's/#LoadModule cgid_module/LoadModule cgid_module/' /usr/local/apache2/conf/httpd.conf && \ + sed -i 's/#LoadModule cgi_module/LoadModule cgi_module/' /usr/local/apache2/conf/httpd.conf && \ + echo 'ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"' >> /usr/local/apache2/conf/httpd.conf && \ + echo '<Directory "/usr/local/apache2/cgi-bin">' >> /usr/local/apache2/conf/httpd.conf && \ + echo ' AllowOverride None' >> /usr/local/apache2/conf/httpd.conf && \ + echo ' Options +ExecCGI' >> /usr/local/apache2/conf/httpd.conf && \ + echo ' Require all granted' >> /usr/local/apache2/conf/httpd.conf && \ + echo '</Directory>' >> /usr/local/apache2/conf/httpd.conf && \ + echo 'DirectoryIndex index.pl index.html' >> /usr/local/apache2/conf/httpd.conf && \ + echo 'AddHandler cgi-script .pl' >> /usr/local/apache2/conf/httpd.conf + +# Copy the CGI script +COPY index.pl /usr/local/apache2/cgi-bin/index.pl +RUN chmod 755 /usr/local/apache2/cgi-bin/index.pl + +# Create a redirect from / to /cgi-bin/index.pl +RUN echo '<meta http-equiv="refresh" content="0;url=/cgi-bin/index.pl">' > /usr/local/apache2/htdocs/index.html + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget -qO- http://127.0.0.1:80/ || exit 1 diff --git a/docker-image/Justfile b/docker-image/Justfile new file mode 100644 index 0000000..ebb9c1e --- /dev/null +++ b/docker-image/Justfile @@ -0,0 +1,21 @@ +VERSION := "1.0.0" +REGISTRY := "r0.lan.buetow.org:30001" +IMAGE := "ipv6test" + +# Build the Docker image +build: + docker build -t {{IMAGE}}:{{VERSION}} . + +# Build and push to f3s registry +f3s: + docker build -t {{IMAGE}}:{{VERSION}} . + docker tag {{IMAGE}}:{{VERSION}} {{REGISTRY}}/{{IMAGE}}:{{VERSION}} + docker push {{REGISTRY}}/{{IMAGE}}:{{VERSION}} + +# Run locally for testing +run: + docker run -it --rm -p 8080:80 {{IMAGE}}:{{VERSION}} + +# Shell into the container for debugging +shell: + docker run -it --rm {{IMAGE}}:{{VERSION}} /bin/sh diff --git a/docker-image/index.pl b/docker-image/index.pl new file mode 100644 index 0000000..596a068 --- /dev/null +++ b/docker-image/index.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl + +# This is QUICK AND DIRTY! + +use strict; +use warnings; + +print <<END; +Content-type: text/html + +<html> +<head> +<title>The Ultimate IPv6 Test Site</title> +</head> +<body> + +Congratulations, you have connected to a server that will display your method of connection, either IPv6 (preferred) or IPv4 (old and crusty). Well IPv6 is already ~15 years old either but not as old as IPv4 ;) +<br /><br /> +Nevertheless, please choose your destiny: +<ul> + <li><a href="http://ipv6.buetow.org">ipv6.buetow.org</a> for IPv6 & IPv4 Test</li> + <li><a href="http://test4.ipv6.buetow.org">test4.ipv6.buetow.org</a> for IPv4 Only Test</li> + <li><a href="http://test6.ipv6.buetow.org">test6.ipv6.buetow.org</a> for IPv6 Only Test</li> +</ul> +If your browser times-out when trying to connect to this server then you do not have an IPv6 or IPv4 path (depends on which test you are running) to the server. If your browser returns an error that the host cannot be found then the DNS servers you are using are unable to resolve the AAAA or A DNS record (depends on which test you are running again) for the server. If your browser is able to connect to the "IPv6 Only Test", yet using the "IPv6 & IPv4 Test" returns a page stating you are using IPv4, then your browser and/or IP stack in your machine are preferring IPv4 over IPv6. It also might be that your operating system supports IPv6 but your web-browser doesn't. +END + +if ($ENV{SERVER_NAME} eq 'ipv6.buetow.org') { + print "<h3>IPv6 & IPv4 Test Results:</h3>\n"; + +} elsif ($ENV{SERVER_NAME} eq 'test6.ipv6.buetow.org') { + print "<h3>IPv6 Only Test Results:</h3>\n"; + +} elsif ($ENV{SERVER_NAME} eq 'test4.ipv6.buetow.org') { + print "<h3>IPv4 Only Test Results:</h3>\n"; +} + +print "<pre>You are using <b>" . do { + if ($ENV{REMOTE_ADDR} =~ /(?:\d+\.){3}\d/) { + 'IPv4' + } else { + 'IPv6' + } +} . "</b>\n"; + + +chomp (my $remote = `host $ENV{REMOTE_ADDR}`); +chomp (my $server = `host $ENV{SERVER_ADDR}`); +chomp (my $server0 = `host $ENV{SERVER_NAME}`); +chomp (my $digremote = `dig -x $ENV{REMOTE_ADDR}`); +chomp (my $digserver = `dig -x $ENV{SERVER_ADDR}`); +chomp (my $digserver0 = `dig -t any $ENV{SERVER_NAME}`); + +print <<END; +Client address: $ENV{REMOTE_ADDR} +Server address: $ENV{SERVER_ADDR} + +<b>Client address reverse DNS lookup:</b> +$remote + +<b>Server address reverse DNS lookup:</b> +$server + +<b>Server hostname DNS lookup:</b> +$server0 + +<b>Advanced client address reverse DNS lookup:</b> +$digremote + +<b>Advanced server address reverse DNS lookup:</b> +$digserver + +<b>Advanced server hostname DNS lookup:</b> +$digserver0 +</pre> +<hr /> +Thanks for visiting, please recommend this test to your friends and colleagues. Any comments go to <a href="http://contact.buetow.org">Paul Buetow</a>. +</body> +</html> +END |
