Skip to content

Instantly share code, notes, and snippets.

@praswicaksono
Created October 15, 2024 06:33
Show Gist options
  • Save praswicaksono/6f9e0b55e4f92e478b7b5e903d47cf5e to your computer and use it in GitHub Desktop.
Save praswicaksono/6f9e0b55e4f92e478b7b5e903d47cf5e to your computer and use it in GitHub Desktop.
services:
replace_me:
image: replace_me
build:
context: .
volumes:
- ./:/opt/www
environment:
- APP_ENV=dev
- SCAN_CACHEABLE=false
networks:
- main
deploy:
mode: replicated
replicas: 1
networks:
main:
external: true
name: main_network
FROM alpine:3.20
ARG timezone
ENV TIMEZONE=${timezone:-"Asia/Jakarta"} \
APP_ENV=prod \
SCAN_CACHEABLE=(true)
RUN wget https://dl.static-php.dev/static-php-cli/bulk/php-8.3.11-cli-linux-x86_64.tar.gz \
&& tar zxvf php-8.3.11-cli-linux-x86_64.tar.gz \
&& mv php /usr/local/bin/php \
&& chmod +x /usr/local/bin/php
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
# update
RUN set -ex \
# show php version and extensions
&& php -v \
&& php -m \
&& php --ri swoole \
# ---------- some config ----------
# # - config PHP
&& { \
echo "upload_max_filesize=128M"; \
echo "post_max_size=128M"; \
echo "memory_limit=1G"; \
echo "date.timezone=${TIMEZONE}"; \
} | tee lib/php.ini \
# - config timezone
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
# ---------- clear works ----------
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
WORKDIR /opt/www
# Composer Cache
# COPY ./composer.* /opt/www/
# RUN composer install --no-dev --no-scripts
COPY . /opt/www
RUN composer install --no-dev -o
EXPOSE 9501
ENTRYPOINT ["php", "/opt/www/index.php"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment