Skip to content

Instantly share code, notes, and snippets.

@santarinto
Last active October 12, 2023 11:59
Show Gist options
  • Save santarinto/d51e15109c84f2ab065da959b1f37296 to your computer and use it in GitHub Desktop.
Save santarinto/d51e15109c84f2ab065da959b1f37296 to your computer and use it in GitHub Desktop.
Dcokerfile example fot php:8.2
FROM php:8.2-fpm-alpine
WORKDIR /opt/app
EXPOSE 8090 9003
ENV RUNNING_IN_DOCKER true
RUN \
# Add user and group
addgroup -S backend && adduser -S -G backend backend \
# Add dir for app
&& mkdir -p /opt/app && chown -R backend:backend /opt/app \
# Install software
&& apk update && apk --no-cache add \
zsh \
curl \
git \
vim \
htop \
# Install composer
&& curl -sS https://getcomposer.org/installer | php \
&& chmod +x composer.phar && mv composer.phar /usr/local/bin/composer \
# Install profile for ZSH
&& mkdir -p /home/backend/.antigen && \
curl -L git.io/antigen > /home/backend/.antigen/antigen.zsh && \
curl -L https://gist.githubusercontent.com/santarinto/95c67a5b040bcb1b212173b559ba532d/raw/6432471cd06fbf477d0d903c22e35178014b8d55/.dockershell.sh > /home/backend/.zshrc && \
chown -R backend:backend /home/backend/.antigen /home/backend/.zshrc \
# Install PHP deps
&& set -x \
&& apk add --no-cache --virtual \
.build-deps \
postgresql-dev \
unixodbc-dev \
freetds-dev \
&& docker-php-ext-configure \
pdo_odbc --with-pdo-odbc=unixODBC,/usr \
&& docker-php-ext-install \
pdo_pgsql \
pdo_odbc
COPY ./entrypoint.zsh /usr/local/bin/entrypoint
COPY ./www.conf /usr/local/etc/php-fpm.d/www.conf
RUN chmod +x /usr/local/bin/entrypoint \
&& chown backend:backend /usr/local/bin/entrypoint \
&& mkdir -p /home/backend/env \
&& chown backend:backend /home/backend/env
USER backend
RUN /bin/zsh /home/backend/.zshrc
CMD ["/usr/local/bin/entrypoint"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment