diff --git a/.github/workflows/google.yml b/.github/workflows/google.yml new file mode 100644 index 0000000..a1018d2 --- /dev/null +++ b/.github/workflows/google.yml @@ -0,0 +1,76 @@ +# This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when a release is created +# +# To configure this workflow: +# +# 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc. +# +# 2. Set up secrets in your workspace: GKE_PROJECT with the name of the project and GKE_SA_KEY with the Base64 encoded JSON service account key (https://github.com/GoogleCloudPlatform/github-actions/tree/docs/service-account-key/setup-gcloud#inputs). +# +# 3. Change the values for the GKE_ZONE, GKE_CLUSTER, IMAGE, and DEPLOYMENT_NAME environment variables (below). +# +# For more support on how to run the workflow, please visit https://github.com/GoogleCloudPlatform/github-actions/tree/master/example-workflows/gke + +name: Build and Deploy to GKE + +on: push + +env: + PROJECT_ID: [Project] # TODO: update to project + CLOUDSDK_CORE_PROJECT: [Project] # TODO: update to project + GKE_CLUSTER: [cluster] # TODO: update to cluster name + GKE_REGION: us-central1 # TODO: update to region + DEPLOYMENT_NAME: roundcube # TODO: update to deployment name + IMAGE: roundcube + + +jobs: + setup-build-publish-deploy: + name: Setup, Build, Publish, and Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + # Setup gcloud CLI + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.3 + with: + service_account_key: ${{ secrets.GKE_SA_KEY }} + project_id: ${{ secrets.GKE_PROJECT }} + + # Configure Docker to use the gcloud command-line tool as a credential + # helper for authentication + - run: |- + gcloud --quiet auth configure-docker + + # Get the GKE credentials so we can deploy to the cluster + - run: |- + gcloud container clusters get-credentials "$GKE_CLUSTER" --region "$GKE_REGION" + + # Build the Docker image + - name: Build + run: |- + docker build \ + --tag "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \ + --build-arg GITHUB_SHA="$GITHUB_SHA" \ + --build-arg GITHUB_REF="$GITHUB_REF" \ + . + + # Push the Docker image to Google Container Registry + - name: Publish + run: |- + docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" + + # Set up kustomize + - name: Set up Kustomize + run: |- + curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 + chmod u+x ./kustomize + + # Deploy the Docker image to the GKE cluster + - name: Deploy + run: |- + ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA + ./kustomize build . | kubectl apply -f - + kubectl rollout status deployment/$DEPLOYMENT_NAME + kubectl get services -o wide diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..281bcd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +roundcube/config.inc.php +docker-compose.yml diff --git a/README.md b/README.md index 3f560ff..8c7be6c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ roundcube-docker ================ -Installs roundcube 1.1.1 inside a docker container. +Installs roundcube 1.4.3 in a docker container. The installation may be used on your server, but also as a standalone -IMAP client (if you skip the step 1. below). +IMAP client (if you skip the step 2 below). Steps: - 1. Customize `roundcube/config.inc.php`. If the file is unmodified, + 1. `cp roundcube/config.inc.php.sample roundcube/config.inc.php`. + 2. Customize `roundcube/config.inc.php`. If the file is unmodified, Roundcube will show a generic login page where the user can -specify IMAP server. - 2. Launch `sudo ./start.sh` to create roundcube image and start +specify IMAP server. Comment out the use_https line if you're not using +SSL. + 3. Launch `sudo ./start.sh` to create roundcube image and start it with port forwarding at 127.0.0.1:8081. You may use LISTEN and PORT env. variables to change the default listening address and port. - 3. Update your web server to proxy connections. + 4. Update your web server to proxy connections. The SQLite database for contacts, settings, etc. is kept in `/rc` inside roundcube-data container. Even if you delete diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample new file mode 100644 index 0000000..07e2003 --- /dev/null +++ b/docker-compose.yml.sample @@ -0,0 +1,37 @@ +version: "2.3" +services: + nginx-proxy: + image: jwilder/nginx-proxy + container_name: nginx-proxy + ports: + - "80:80" + - "443:443" + volumes: + - "/home/example/nginx/vhost.d:/etc/nginx/vhost.d" + - "/home/example/nginx/html:/usr/share/nginx/html" + - "/home/example/nginx/certs:/etc/nginx/certs" + - "/var/run/docker.sock:/tmp/docker.sock:ro" + + letsencrypt-nginx-proxy-companion: + image: jrcs/letsencrypt-nginx-proxy-companion + container_name: letsencrypt + volumes: + - "/var/run/docker.sock:/var/run/docker.sock:ro" + volumes_from: + - "nginx-proxy" + + roundcube: + build: ./roundcube + image: roundcube + container_name: roundcube + restart: unless-stopped + environment: + - VIRTUAL_HOST=mail.example.com + - LETSENCRYPT_HOST=mail.example.com + - LETSENCRYPT_EMAIL=example@example.com + volumes: + - "rc-data:/rc" + +volumes: + rc-data: + driver: local diff --git a/roundcube/Dockerfile b/roundcube/Dockerfile index c792aba..9ea76e0 100644 --- a/roundcube/Dockerfile +++ b/roundcube/Dockerfile @@ -1,24 +1,27 @@ -FROM debian:stable -ENV DEBIAN_FRONTEND noninteractive -ENV TERM xterm -MAINTAINER Round Cube +FROM ubuntu:20.04 +LABEL maintainer="Michael Bushey " + +RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list &&\ + apt-get update &&\ + apt-get -y upgrade &&\ + apt-get install -y --no-install-recommends \ + apt-transport-https ca-certificates nginx wget sqlite3 procps \ + php7.4-fpm php7.4-intl php7.4-sqlite3 \ + php-pear php-net-smtp php-mail-mime &&\ + rm -rf /var/lIB/apt/lists/* + -RUN apt-get -y update && apt-get -y upgrade -RUN apt-get install -y --no-install-recommends \ - nginx php5-fpm nano wget sqlite3 procps \ - php5-mcrypt php5-intl php5-sqlite php-pear \ - php-net-smtp php-mail-mime WORKDIR /root -# when roundcube grows older, change version in the download link, but also in the 'mv' command -RUN \ - wget http://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.1.2/roundcubemail-1.1.2.tar.gz -O - | tar xz ;\ - rm -fr /usr/share/nginx/www ;\ - mv /root/roundcubemail-1.1.2 /usr/share/nginx/www ;\ - rm -fr /usr/share/nginx/www/installer ;\ +ARG RC_VER=1.4.3 +RUN rm -fr /usr/share/nginx/www &&\ + wget https://github.com/roundcube/roundcubemail/releases/download/${RC_VER}/roundcubemail-${RC_VER}-complete.tar.gz -O - | tar xz &&\ + mv /root/roundcubemail-${RC_VER} /usr/share/nginx/www &&\ + rm -fr /usr/share/nginx/www/installer &&\ mkdir -p /rc ADD config.inc.php /usr/share/nginx/www/config/ ADD default /etc/nginx/sites-enabled/default ADD launch.sh /root/ +EXPOSE 80 VOLUME /rc CMD [ "bash", "/root/launch.sh" ] diff --git a/roundcube/config.inc.php b/roundcube/config.inc.php.sample similarity index 95% rename from roundcube/config.inc.php rename to roundcube/config.inc.php.sample index 0332b86..1f4d9c8 100644 --- a/roundcube/config.inc.php +++ b/roundcube/config.inc.php.sample @@ -87,3 +87,9 @@ // RFC1766 formatted language name like en_US, de_DE, de_CH, fr_FR, pt_BR $config['language'] = 'en_US'; +// ---------------------------------- +// Set https +// ---------------------------------- +$config['use_https'] = true; + +$config['skin'] = 'elastic'; diff --git a/roundcube/default b/roundcube/default index f070592..2343525 100644 --- a/roundcube/default +++ b/roundcube/default @@ -8,7 +8,7 @@ server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; diff --git a/roundcube/launch.sh b/roundcube/launch.sh index 7be55dc..e4eef39 100644 --- a/roundcube/launch.sh +++ b/roundcube/launch.sh @@ -9,7 +9,7 @@ mkdir -p /rc/tmp chown -R www-data:www-data /rc service nginx start -service php5-fpm start +service php7.4-fpm start tail -F /var/log/nginx/access.log diff --git a/start.sh b/start.sh index dd43f4a..804454b 100755 --- a/start.sh +++ b/start.sh @@ -27,7 +27,7 @@ if [ "$?" -ne 0 ] ; then fi # 1. Create image with roundcube -sudo $DOCKER build -t thinred/roundcube ./roundcube +sudo $DOCKER build -t mabushey/roundcube ./roundcube # 2. Start it and attach rc-data volumes -sudo $DOCKER run -p ${LISTEN}:${PORT}:80 --volumes-from roundcube-data -d --name roundcube thinred/roundcube +$DOCKER run --restart unless-stopped -p ${LISTEN}:${PORT}:80 --volumes-from roundcube-data -d --name roundcube mabushey/roundcube