diff --git a/.gitignore b/.gitignore index d344ba6..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -config.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a581caa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +FROM phusion/baseimage:0.9.0 +MAINTAINER Romain Pignolet + +WORKDIR /root + +RUN apt-get update +RUN apt-get -y install build-essential \ + libanyevent-httpd-perl \ + libdata-uuid-libuuid-perl \ + libdatetime-perl \ + libdbd-sqlite3-perl \ + libdbi-perl \ + libemail-address-perl \ + libemail-mime-perl \ + libhtml-parser-perl \ + libhtml-strip-perl \ + libhttp-tiny-perl \ + libhttp-date-perl \ + libimage-size-perl \ + libio-socket-ssl-perl \ + libjson-perl \ + libjson-xs-perl \ + liblocale-gettext-perl \ + libswitch-perl \ + libexpat1-dev \ + git \ + nginx + +RUN cpan; true + +RUN curl -L -O http://search.cpan.org/CPAN/authors/id/C/CI/CINDY/AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2.tar.gz && \ + tar xf AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2.tar.gz && \ + cd AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2 && \ + perl Makefile.PL && \ + make install + +RUN git clone https://github.com/brong/Net-CardDAVTalk.git && \ + cd Net-CardDAVTalk && \ + perl Makefile.PL && \ + make install + +RUN perl -MCPAN -e 'my $c = "CPAN::HandleConfig"; $c->load(doit => 1, autoconfig => 1); $c->edit(prerequisites_policy => "follow"); $c->edit(build_requires_install_policy => "yes"); $c->commit' + +RUN cpan Class::ReturnValue Class::Accessor Set::Infinite \ + DateTime::Set DateTime::Event::Recurrence DateTime::TimeZone DateTime::Event::ICal \ + Text::vFile::asData Test::LongString Test::Warn \ + Data::ICal UNIVERSAL::require Mail::IMAPTalk XML::Parser \ + XML::SemanticDiff XML::Spice Email::Sender::Transport::SMTPS \ + Net::DAVTalk Net::CalDAVTalk AnyEvent::HTTPD::CookiePatch \ + AnyEvent::IMAP Cookie::Baker Date::Parse HTML::GenerateUtil \ + Email::Sender:Simple Moose IO:All AnyEvent:HTTP Net::Server::PreFork \ + List::Pairwise IO::LockedFile Template EV Net::DNS || true + +RUN mkdir -p /home/jmap/data + +COPY . /home/jmap/jmap-perl + +WORKDIR /home/jmap/jmap-perl + +RUN rm /etc/nginx/sites-enabled/default + +COPY docker/nginx.conf /etc/nginx/sites-enabled/ + +COPY docker/entrypoint.sh /root/ + +EXPOSE 80 + +ENTRYPOINT ["sh", "/root/entrypoint.sh"] diff --git a/config.json b/config.json new file mode 100644 index 0000000..e1b77d0 --- /dev/null +++ b/config.json @@ -0,0 +1,11 @@ +{ + "client_id" : "XXX", + "client_secret": "YYY", + "auth_url" : "https://accounts.google.com/o/oauth2/auth", + "token_url" : "https://accounts.google.com/o/oauth2/token", + "callback_url" : "https://proxy.jmap.io/cb/google", + "scopes" : [ + "https://www.googleapis.com/auth/userinfo.email", + "https://mail.google.com/" + ] +} diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 64191f9..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -FROM phusion/baseimage:0.9.0 -MAINTAINER Romain Pignolet - -WORKDIR /root - -RUN apt-get update -RUN apt-get -y install build-essential \ - libanyevent-httpd-perl \ - libdata-uuid-libuuid-perl \ - libdatetime-perl \ - libdbd-sqlite3-perl \ - libdbi-perl \ - libemail-address-perl \ - libemail-mime-perl \ - libhtml-parser-perl \ - libhtml-strip-perl \ - libhttp-tiny-perl \ - libhttp-date-perl \ - libimage-size-perl \ - libio-socket-ssl-perl \ - libjson-perl \ - libjson-xs-perl \ - liblocale-gettext-perl \ - libswitch-perl \ - git \ - nginx - -RUN cpan; true - -RUN curl -L -O http://search.cpan.org/CPAN/authors/id/C/CI/CINDY/AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2.tar.gz && \ - tar xf AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2.tar.gz && \ - cd AnyEvent-HTTPD-SendMultiHeaderPatch-v0.1.2 && \ - perl Makefile.PL && \ - make install - -RUN cpan AnyEvent::HTTPD::CookiePatch AnyEvent::IMAP Cookie::Baker Date::Parse HTML::GenerateUtil Email::Sender:Simple Moose IO:All AnyEvent:HTTP Net::Server::PreFork - -RUN mkdir -p /home/jmap/data - -RUN cd /home/jmap && git clone -b docker https://github.com/rpignolet/jmap-perl.git - -WORKDIR /home/jmap/jmap-perl - -RUN rm /etc/nginx/sites-enabled/default - -ADD nginx.conf /etc/nginx/sites-enabled/ -ADD entrypoint.sh /root/ - -EXPOSE 80 - -ENTRYPOINT ["sh", "/root/entrypoint.sh"] - diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index a7d004c..13bc936 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -7,8 +7,9 @@ sed -i "s?https://proxy.jmap.io?http://$IP?g" ./bin/server.pl ./htdocs/landing.h # Or can be occurrence of previous docker IP sed -i "s?http://172[^/]*?http://$IP?g" ./bin/server.pl ./htdocs/landing.html ./JMAP/API.pm ./JMAP/DB.pm +export jmaphost=$IP + service nginx start perl ./bin/server.pl & -#perl ./bin/syncserver.pl & perl ./bin/apiendpoint.pl diff --git a/docker/nginx.conf b/docker/nginx.conf index eab5c3c..0363006 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,8 +1,12 @@ server { listen 80; + listen 443; + ssl on; + ssl_certificate /home/jmap/jmap-perl/docker/ssl/self-ssl.crt; + ssl_certificate_key /home/jmap/jmap-perl/docker/ssl/self-ssl.key; + root /home/jmap/jmap-perl/htdocs/; index index.html index.htm; - server_name proxy.jmap.io; location / { diff --git a/docker/ssl/self-ssl.crt b/docker/ssl/self-ssl.crt new file mode 100644 index 0000000..c621212 --- /dev/null +++ b/docker/ssl/self-ssl.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICATCCAWoCCQCgtjAVJ/JxQjANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE1MTAyNzA4NTExNFoXDTE2MTAyNjA4NTExNFowRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsm9F +vEFh0fCz916vNBf4F7+tsAKR/2SXZIhL+GUvCX6WZZGmzKf9myG1xA6uooZGGwcE +xXofMu5GKHPfani5SCe3Cs9StS1sAmd+9vBeiF1aGTaX5Ynqvmaw8t+TlshJPj9r +2eB871pd50wo0TzvkVabrFiESGPKY/fjEHLq8HcCAwEAATANBgkqhkiG9w0BAQsF +AAOBgQBiGDRl4pXT+E2o2zWAQSK6NJW9nWJvi6Eicali9uLiRUfp1cH57p7PBKhV +7B6YEFNVMrJ6oA6yrASro3zrHnY4Llq3UAqqJUmVZYtJXWUzN/PoeAnWK1SS5EO+ +pHq9U/lrqBzX+vVYLvDjF/iV+tE/sgm4kVg2ODXCj8myJ/He1g== +-----END CERTIFICATE----- diff --git a/docker/ssl/self-ssl.csr b/docker/ssl/self-ssl.csr new file mode 100644 index 0000000..d97d020 --- /dev/null +++ b/docker/ssl/self-ssl.csr @@ -0,0 +1,11 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBhDCB7gIBADBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEh +MB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQCyb0W8QWHR8LP3Xq80F/gXv62wApH/ZJdkiEv4ZS8JfpZl +kabMp/2bIbXEDq6ihkYbBwTFeh8y7kYoc99qeLlIJ7cKz1K1LWwCZ3728F6IXVoZ +Npflieq+ZrDy35OWyEk+P2vZ4HzvWl3nTCjRPO+RVpusWIRIY8pj9+MQcurwdwID +AQABoAAwDQYJKoZIhvcNAQELBQADgYEAV9cECmy/Rzb+V0yEAiIZBTeOQ+bNw1aq +S6P6MU2uh1S3Zp0R686L5XDEDVu2w3xqMnlL+tzsCRZUdU0xW34YEcyeJfWF71Fa +vCNg5CsofwaG7b/LBdX3EV/zgEKAm19trrodHrvB9UCe4msK8YtHNFIX+8wdckQ3 +ouibKzQ4KiU= +-----END CERTIFICATE REQUEST----- diff --git a/docker/ssl/self-ssl.key b/docker/ssl/self-ssl.key new file mode 100644 index 0000000..4f09714 --- /dev/null +++ b/docker/ssl/self-ssl.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQCyb0W8QWHR8LP3Xq80F/gXv62wApH/ZJdkiEv4ZS8JfpZlkabM +p/2bIbXEDq6ihkYbBwTFeh8y7kYoc99qeLlIJ7cKz1K1LWwCZ3728F6IXVoZNpfl +ieq+ZrDy35OWyEk+P2vZ4HzvWl3nTCjRPO+RVpusWIRIY8pj9+MQcurwdwIDAQAB +AoGAF3Eq9jqYwV4gJqWX2v4zJ9uU1ATibW0nvptxb6bLcTHiTGHASi7f0JuzJ5jO +NKfzWeWoKNGMe8J2ESZ3+aL2pF3VL8pJXsnhKGUZ8IdSik1HQO2ota8DzbQ6xKon +zF+3mffOmF/5//17HnALKBt8JJlHl5UGxXbHcZg19jHiK9ECQQDlxegE7c7wzJdS +zO8fE73Vz4LSuTINsgoKQfCmt7FqrVp7uHKfNXl61v8irckZcafZthiJsnqDt3iD +nBCbUy7lAkEAxs061JZ2OcUchNZ+eUBG4LGXQUWJc37LE3SDLQLy/2p7qFRuX7bm +dQzit1GFLQ7yTlRWH597Sm5d759aePjQKwJBALj6EkeliyugCVLHWNoT8ofmftNV +9E3CPwLzAuG0kEfpNybS3rP9QMb7vnoUngi1zwMd7bMs1CSl14dcZKIm3WECQQCL +wYsyF/RU+HTsDb4rjzxEiZRDlpbiUqiArM/qvMAHPtxfobtWHkY00zIunWh6HJ/K +4Q8KfBs4YA45flUj5gaxAkEAmRPjmQQjkKOaoR7qxedS/xrcaQOteKjbOnWAYC0n +OArshjCNPAJy47iU/o2nAyV8vwaoBUOCepshuyLl+m5PQg== +-----END RSA PRIVATE KEY-----