Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@drubb
Last active March 21, 2021 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drubb/40edc29f3df096c2d23f603b40ae3ebb to your computer and use it in GitHub Desktop.
Save drubb/40edc29f3df096c2d23f603b40ae3ebb to your computer and use it in GitHub Desktop.
Setup browser-based Phpstorm instance for Drupal and JavaScript development using Docker and Caddy Server
your.editor.domain {
reverse_proxy phpstorm:8887
basicauth {
username WHATEVERYOUGENERATEASSECRETKEYUSINGCADDY
}
}
your.preview.domain {
reverse_proxy phpstorm:3000
basicauth {
username WHATEVERYOUGENERATEASSECRETKEYUSINGCADDY
}
}
version: "2"
services:
caddy:
image: caddy:2
container_name: caddy
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./data/caddy/data:/data
- ./data/caddy/config:/config
depends_on:
- phpstorm
phpstorm:
build:
context: .
dockerfile: Dockerfile
container_name: phpstorm
environment:
- DRUSH_OPTIONS_URI=your.preview.domain
- DRUSH_COMMAND_RUNSERVER_OPTIONS_DEFAULT_SERVER=0.0.0.0:3000
expose:
- 8887
- 9003
volumes:
- ./data/phpstorm:/home/projector-user
restart: always
FROM registry.jetbrains.team/p/prj/containers/projector-phpstorm
ARG DEBIAN_FRONTEND=noninteractive
USER root
RUN apt-get update -yq \
# Install some common packages
&& apt-get install curl sqlite3 wget unzip -yq \
# Install PHP CLI with some extensions for Drupal development
&& apt-get install php-cli php-apcu php-curl php-dom php-gd php-mbstring php-sqlite3 php-zip -yq \
&& apt-get install php-pear php-dev -yq \
&& pear config-set php_ini /etc/php/7.3/cli/php.ini \
&& pecl install xdebug \
&& echo 'xdebug.mode=debug,develop' >> /etc/php/7.3/cli/php.ini \
# Install NodeJS LTS
&& curl -sL https://deb.nodesource.com/setup_lts.x | bash \
&& apt-get install nodejs -yq \
# Install Composer
&& wget https://getcomposer.org/installer \
&& php installer --install-dir=/usr/local/bin --filename=composer \
# Install global Drush launcher
&& wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar \
&& chmod +x /usr/local/bin/drush \
# Clean up some things
&& chown -R projector-user:projector-user /home/projector-user \
&& rm installer \
&& rm -rf /var/lib/apt/lists/*
USER projector-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment