Last active
April 9, 2024 09:50
-
-
Save jafar260698/0a02f388f0d5edcfa953edb083edde22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- deploy | |
build-dev: | |
stage: build | |
only: | |
- dev | |
tags: | |
- dev-my-app-backend | |
#when: manual | |
script: | |
- docker build --rm -t my_app_backend:$CI_PIPELINE_IID . | |
- docker tag my_app_backend:$CI_PIPELINE_IID my_app_backend:latest | |
deploy-dev: | |
stage: deploy | |
only: | |
- dev | |
tags: | |
- dev-my-app-backend | |
#when: manual | |
script: | |
- docker service update --with-registry-auth --image my_app_backend:$CI_PIPELINE_IID my_app_backend | |
- docker ps | grep my_app_backend | awk '{print $12}' > export.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
php: | |
build: | |
context: . | |
environment: | |
- APP_ENV=${APP_ENV} | |
- CONTAINER_ROLE=app | |
- DB_HOST=database | |
working_dir: /var/www | |
volumes: | |
- ./:/var/www/html:rw | |
ports: | |
- 8080:80 | |
depends_on: | |
- database | |
networks: | |
- appnetwork | |
database: | |
image: mysql | |
container_name: mysql | |
hostname: database | |
ports: | |
- "330:3306" | |
volumes: | |
- ./mysql/data:/var/lib/mysql | |
environment: | |
- MYSQL_DATABASE=#db | |
- MYSQL_USER=jafar | |
- MYSQL_PASSWORD=2606 | |
- MYSQL_ROOT_PASSWORD=2606 | |
networks: | |
- appnetwork | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
container_name: phpmyadmin | |
environment: | |
- PMA_HOST=database | |
- PMA_PORT=3306 | |
ports: | |
- "3400:80" | |
depends_on: | |
- database | |
networks: | |
- appnetwork | |
networks: | |
appnetwork: | |
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.2-apache | |
# 1. Install development packages and clean up apt cache. | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
g++ \ | |
git \ | |
libonig-dev \ | |
libbz2-dev \ | |
libfreetype6-dev \ | |
libicu-dev \ | |
libjpeg-dev \ | |
libmcrypt-dev \ | |
libpng-dev \ | |
libreadline-dev \ | |
sudo \ | |
unzip \ | |
zip \ | |
&& rm -rf /var/lib/apt/lists/* | |
# 2. Apache configs + document root. | |
RUN echo "ServerName laravel-app.local" >> /etc/apache2/apache2.conf | |
ENV APACHE_DOCUMENT_ROOT=/var/www/html | |
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf | |
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | |
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin- | |
RUN a2enmod rewrite headers | |
# 4. Start with base PHP config, then add extensions. | |
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" | |
RUN docker-php-ext-install \ | |
bcmath \ | |
bz2 \ | |
calendar \ | |
iconv \ | |
intl \ | |
mbstring \ | |
opcache \ | |
pdo \ | |
pdo_mysql | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
RUN composer install | |
RUN php artisan key:generate | |
WORKDIR /var/www/html | |
EXPOSE 80 | |
EXPOSE 443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -f "vendor/autoload.php" ]; then | |
composer install --no-progress --no-interaction | |
fi | |
if [ ! -f ".env" ]; then | |
echo "Creating env file for env $APP_ENV" | |
cp .env.example .env | |
else | |
echo "env file exists." | |
fi | |
role=${CONTAINER_ROLE:-app} | |
if [ "$role" = "app" ]; then | |
php artisan migrate | |
php artisan key:generate | |
php artisan cache:clear | |
php artisan config:clear | |
php artisan route:clear | |
php artisan db:seed | |
php artisan serve --port=$PORT --host=0.0.0.0 --env=.env | |
exec docker-php-entrypoint "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment