diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b3167be --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +IMAP_HOST=mail.example.com +SMTP_HOST=mail.example.com +IMAP_SSL=true \ No newline at end of file diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 0000000..69b5f61 --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,42 @@ +name: Create and publish a Docker image + +on: + push: + tags: + - v* + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4511e7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +docker-compose.override.yml +.env +.env.* +!.env.example \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f92f152 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM caddy:2.8.4-alpine AS caddy + +FROM php:8.3-fpm-alpine + +RUN apk update && apk add supervisor + +COPY --from=caddy /usr/bin/caddy /usr/bin/caddy + +# Configure supervisor +RUN mkdir -p /etc/supervisor.d/ +COPY ./docker/supervisord.ini /etc/supervisor.d/supervisord.ini + +# Configure Caddy web server +COPY ./docker/Caddyfile /etc/caddy/Caddyfile + +# Configure PHP-FPM +RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini + +WORKDIR /src +COPY ./src /var/www/html + +EXPOSE 80 +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.d/supervisord.ini"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ca237f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Autodiscover + +IMAP/SMTP autodiscover for email clients. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0f5b0a0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + autodiscover: + build: . + ports: + - "8000:80" + env_file: + - .env \ No newline at end of file diff --git a/docker/Caddyfile b/docker/Caddyfile new file mode 100644 index 0000000..d6c723e --- /dev/null +++ b/docker/Caddyfile @@ -0,0 +1,4 @@ +:80 { + root * /var/www/html + php_fastcgi localhost:9000 +} \ No newline at end of file diff --git a/docker/supervisord.ini b/docker/supervisord.ini new file mode 100644 index 0000000..afebf9b --- /dev/null +++ b/docker/supervisord.ini @@ -0,0 +1,16 @@ +[supervisord] +nodaemon=true + +[program:caddy] + command=/usr/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile + stdout_logfile=/dev/stdout + stdout_logfile_maxbytes=0 + stderr_logfile=/dev/stderr + stderr_logfile_maxbytes=0 + +[program:php-fpm] + command=php-fpm + stdout_logfile=/dev/stdout + stdout_logfile_maxbytes=0 + stderr_logfile=/dev/stderr + stderr_logfile_maxbytes=0 \ No newline at end of file diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..86103b6 --- /dev/null +++ b/src/index.php @@ -0,0 +1,40 @@ +(.*)<\/EMailAddress>/', $raw, $matches); +?> + + + + + email + settings + + IMAP + + 993 + off" . $matches[1] . "" ?> + on + + on + + + SMTP + + 587 + off" . $matches[1] . "" ?> + off + off + on + off + off + + + +