Skip to content

Instantly share code, notes, and snippets.

@connerbw
Last active Aug 13, 2020
Embed
What would you like to do?
PHP & Go, Together At Last
# -----------------------------------------------------------------------------
# Build RoadRunner
# -----------------------------------------------------------------------------
FROM golang:1.14 as builder
ENV CGO_ENABLED=0
ENV GO111MODULE=on
RUN apt-get update
WORKDIR /go/src/roadrunner
COPY ./server/ .
RUN go build -trimpath -ldflags "-s -w" -o rr
# -----------------------------------------------------------------------------
# Build PHP
# -----------------------------------------------------------------------------
FROM php:7.4-cli
RUN apt-get update && apt-get install -y --no-install-recommends \
libzip-dev \
unzip
# Install PHP Extensions
RUN docker-php-ext-install zip \
&& docker-php-ext-install sockets \
&& docker-php-ext-install opcache \
&& docker-php-ext-enable opcache
# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === rtrim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& mv composer.phar /usr/local/bin/composer
WORKDIR /var/www/app
# Setup Spiral
RUN composer create-project spiral/app . --no-scripts
# Or comment above, uncomment below, and copy Spiral
# COPY ./src/ .
RUN composer install
RUN cp .env.sample .env \
&& php app.php encrypt:key -m .env \
&& php ./app.php configure
# Install our compiled RR
COPY --from=builder /go/src/roadrunner/rr /usr/local/bin/rr
CMD ["/usr/local/bin/rr", "serve", "-d", "-v", "-c", "/var/www/app/.rr.yaml", "-o", "metrics.address=0.0.0.0:2112"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment