sintonia docker fix: dev container startup
This commit is contained in:
parent
f17ee781a2
commit
18ad58fd68
1
.env.dev
1
.env.dev
|
@ -9,3 +9,4 @@ SINTONIA_VITE_PORT=9877
|
||||||
SINTONIA_USER=sintonia
|
SINTONIA_USER=sintonia
|
||||||
SINTONIA_UID=1000
|
SINTONIA_UID=1000
|
||||||
SINTONIA_NODE_VERSION=22.13.0
|
SINTONIA_NODE_VERSION=22.13.0
|
||||||
|
SINTONIA_CONFIG_FILEPATH=./dev/sintonia-webapp/laravel/.env.dev.example
|
101
Dockerfile
101
Dockerfile
|
@ -284,7 +284,7 @@ ENV LIBRETIME_VERSION=$LIBRETIME_VERSION
|
||||||
#======================================================================================#
|
#======================================================================================#
|
||||||
|
|
||||||
# Use PHP as the base
|
# Use PHP as the base
|
||||||
FROM php:8.2-cli AS sintonia-webapp
|
FROM php:8.2-cli AS sintonia-webapp-base
|
||||||
|
|
||||||
# Arguments defined in docker-compose-dev.yml
|
# Arguments defined in docker-compose-dev.yml
|
||||||
ARG sintonia_user=$SINTONIA_USER
|
ARG sintonia_user=$SINTONIA_USER
|
||||||
|
@ -292,8 +292,6 @@ ARG sintonia_uid=$SINTONIA_UID
|
||||||
ARG sintonia_node_version=$SINTONIA_NODE_VERSION
|
ARG sintonia_node_version=$SINTONIA_NODE_VERSION
|
||||||
ARG sintonia_production=$SINTONIA_PRODUCTION
|
ARG sintonia_production=$SINTONIA_PRODUCTION
|
||||||
|
|
||||||
ENV sintonia_laravel_port $SINTONIA_LARAVEL_PORT
|
|
||||||
ENV sintonia_vite_port $SINTONIA_VITE_PORT
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Install Additional System Dependencies and PHP Extensions
|
# Install Additional System Dependencies and PHP Extensions
|
||||||
|
@ -309,26 +307,27 @@ RUN set -eux && \
|
||||||
libzip-dev \
|
libzip-dev \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
git \
|
git \
|
||||||
libonig-dev && \
|
libonig-dev \
|
||||||
docker-php-ext-configure zip && \
|
libpq-dev
|
||||||
docker-php-ext-configure gd --with-freetype --with-jpeg && \
|
|
||||||
docker-php-ext-install gd exif pcntl bcmath mysqli pdo_mysql mbstring && \
|
|
||||||
if [ ! "$sintonia_production" ]; then \
|
|
||||||
pecl install xdebug; docker-php-ext-enable xdebug; \
|
|
||||||
fi && \
|
|
||||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY ./sintonia_webapp /var/www/sintonia
|
RUN docker-php-ext-configure zip && \
|
||||||
|
docker-php-ext-configure gd --with-freetype --with-jpeg
|
||||||
|
|
||||||
|
RUN docker-php-ext-install gd exif pcntl bcmath mysqli pdo_mysql mbstring && \
|
||||||
|
docker-php-ext-install pdo_pgsql pgsql && \
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Create system user to run Composer and Artisan Commands
|
# Create system user to run Composer and Artisan Commands
|
||||||
RUN set -eux && useradd -G www-data -u $sintonia_uid -d /home/$sintonia_user $sintonia_user && \
|
RUN set -eux && useradd -G www-data -u $sintonia_uid -d /home/$sintonia_user $sintonia_user && \
|
||||||
mkdir -p /home/$sintonia_user/.composer && \
|
mkdir -p /home/$sintonia_user/.composer && \
|
||||||
mkdir -p /var/www/sintonia && \
|
mkdir -p /var/www/sintonia_webapp && \
|
||||||
chown -R $sintonia_user:$sintonia_user /home/$sintonia_user && \
|
chown -R $sintonia_user:$sintonia_user /home/$sintonia_user && \
|
||||||
chown -R $sintonia_user:$sintonia_user /var/www/sintonia
|
chown -R $sintonia_user:$sintonia_user /var/www/sintonia_webapp
|
||||||
|
|
||||||
USER "$sintonia_user"
|
USER "$sintonia_user"
|
||||||
WORKDIR /home/$sintonia_user
|
WORKDIR /home/$sintonia_user
|
||||||
|
# Install composer
|
||||||
|
RUN set -eux && curl -sS https://getcomposer.org/installer | php -- --filename=composer
|
||||||
|
|
||||||
# node and composer installation
|
# node and composer installation
|
||||||
# Download and install nvm:
|
# Download and install nvm:
|
||||||
|
@ -338,24 +337,72 @@ RUN curl -fsSL https://nodejs.org/dist/v$sintonia_node_version/node-v$sintonia_n
|
||||||
|
|
||||||
ENV PATH="/home/$sintonia_user/node-v$sintonia_node_version-linux-x64/bin:/home/$sintonia_user/composer:${PATH}"
|
ENV PATH="/home/$sintonia_user/node-v$sintonia_node_version-linux-x64/bin:/home/$sintonia_user/composer:${PATH}"
|
||||||
|
|
||||||
# Install composer
|
#Build
|
||||||
RUN set -eux && curl -sS https://getcomposer.org/installer | php -- --install-dir=/home/$sintonia_user/ --filename=composer
|
FROM sintonia-webapp-base AS sintonia-webapp-build-common
|
||||||
|
ARG sintonia_config_filepath=$SINTONIA_CONFIG_FILEPATH
|
||||||
|
ARG libretime_config_filepath=$LIBRETIME_CONFIG_FILEPATH
|
||||||
|
|
||||||
WORKDIR /var/www/sintonia
|
USER root
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update && apt-get install yq -y
|
||||||
|
USER "$sintonia_user"
|
||||||
|
|
||||||
|
WORKDIR $HOME
|
||||||
|
COPY --chown=$sintonia_user:$sintonia_user ./tools/populate-laravel-env-file.sh /home/$sintonia_user/
|
||||||
|
COPY --chown=$sintonia_user:$sintonia_user $sintonia_config_filepath /home/$sintonia_user/
|
||||||
|
COPY --chown=$sintonia_user:$sintonia_user $libretime_config_filepath /home/$sintonia_user/
|
||||||
|
RUN chmod +x ./populate-laravel-env-file.sh && \
|
||||||
|
./populate-laravel-env-file.sh /home/$sintonia_user/config.yml /home/$sintonia_user/.env
|
||||||
|
|
||||||
|
# DEV
|
||||||
|
FROM sintonia-webapp-build-common AS sintonia-webapp-dev
|
||||||
|
|
||||||
|
ARG sintonia_laravel_port
|
||||||
|
ARG sintonia_vite_port
|
||||||
|
|
||||||
|
ENV sintonia_laravel_port=${sintonia_laravel_port}
|
||||||
|
ENV sintonia_vite_port=${sintonia_vite_port}
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN pecl install xdebug && docker-php-ext-enable xdebug;
|
||||||
|
USER $sintonia_user
|
||||||
|
|
||||||
|
WORKDIR /var/www/sintonia_webapp
|
||||||
|
#COPY --chown=$sintonia_user:$sintonia_user ./sintonia_webapp/ ./
|
||||||
|
|
||||||
#Package installation
|
#Package installation
|
||||||
RUN git config --global --add safe.directory /var/www/sintonia && \
|
#RUN git config --global --add safe.directory /var/www/sintonia_webapp && \
|
||||||
/home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
# /home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
||||||
set -eux && \
|
# set -eux && \
|
||||||
/home/$sintonia_user/composer --no-cache dump-autoload --no-interaction --no-dev && \
|
# npm i
|
||||||
npm i
|
|
||||||
|
|
||||||
##
|
#RUN php artisan ziggy:generate && mv ziggy.js resources/utils/ziggy.js
|
||||||
|
#RUN cp $HOME/.env ./
|
||||||
|
ENV sintonia_user=${sintonia_user}
|
||||||
### Start server
|
### Start server
|
||||||
CMD if [ ! $sintonia_production ]; then \
|
CMD git config --global --add safe.directory /var/www/sintonia_webapp && \
|
||||||
cd /var/www/sintonia; \
|
/home/$sintonia_user/composer install --no-progress --no-interaction --no-dev --no-autoloader && \
|
||||||
|
/home/$sintonia_user/composer --no-cache dump-autoload --no-interaction --no-dev && \
|
||||||
|
php artisan key:generate && \
|
||||||
|
set -eux && \
|
||||||
|
npm i && \
|
||||||
npx vite --port $sintonia_vite_port --host & \
|
npx vite --port $sintonia_vite_port --host & \
|
||||||
php artisan serve --host=0.0.0.0 --port=$sintonia_laravel_port & \
|
php artisan serve --host=0.0.0.0 --port=$sintonia_laravel_port & \
|
||||||
sleep infinity; \
|
sleep infinity
|
||||||
fi;
|
|
||||||
|
|
||||||
|
|
||||||
|
FROM sintonia-webapp-build-common AS sintonia-webapp-production
|
||||||
|
|
||||||
|
RUN git clone https://git.congegni.net/sintonia_webapp && \
|
||||||
|
cd sintonia_webapp && \
|
||||||
|
php artisan ziggy:generate && \
|
||||||
|
php artisan key:generate && \
|
||||||
|
mv ziggy.js resources/utils/ziggy.js && \
|
||||||
|
npx vite build && \
|
||||||
|
cp -r dist/build/* /var/www/html/ && \
|
||||||
|
rm -rf /var/www/sintonia_webapp/node_modules /var/www/sintonia_webapp/.npm /var/www/sintonia_webapp/.composer /var/www/sintonia_webapp/.git && \
|
||||||
|
rm -rf /home/$sintonia_user/node* /home/$sintonia_user/composer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
APP_NAME=Sintonia
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:vxFbOz6qPvNW2RpEFw/XOWdZ9+X5oXwqnUgjHETJHQM=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_TIMEZONE=UTC
|
||||||
|
APP_URL=http://127.0.0.1
|
||||||
|
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=pgsql
|
||||||
|
DB_HOST=postgres
|
||||||
|
DB_PORT=5432
|
||||||
|
DB_DATABASE=libretime
|
||||||
|
DB_USERNAME=libretime
|
||||||
|
DB_PASSWORD=libretime
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
|
@ -69,12 +69,21 @@ services:
|
||||||
sintonia-webapp:
|
sintonia-webapp:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: sintonia-webapp
|
target: sintonia-webapp-dev
|
||||||
image: sintonia-webapp
|
args:
|
||||||
container_name: sintonia-webapp
|
- sintonia_laravel_port=${SINTONIA_LARAVEL_PORT}
|
||||||
working_dir: /var/www/
|
- sintonia_vite_port=${SINTONIA_VITE_PORT}
|
||||||
|
image: sintonia-webapp-dev
|
||||||
|
container_name: sintonia-webapp-dev
|
||||||
|
working_dir: /var/www/sintonia_webapp
|
||||||
volumes:
|
volumes:
|
||||||
- libretime_storage:/srv/libretime
|
- ./sintonia_webapp:/var/www/sintonia_webapp
|
||||||
|
ports:
|
||||||
|
- ${SINTONIA_LARAVEL_PORT}:${SINTONIA_LARAVEL_PORT}
|
||||||
|
- ${SINTONIA_VITE_PORT}:${SINTONIA_VITE_PORT}
|
||||||
|
environment:
|
||||||
|
- sintonia_laravel_port=${SINTONIA_LARAVEL_PORT}
|
||||||
|
- sintonia_vite_port=${SINTONIA_VITE_PORT}
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -101,26 +101,24 @@ services:
|
||||||
sintonia-webapp:
|
sintonia-webapp:
|
||||||
build:
|
build:
|
||||||
context: ./sintonia_webapp
|
context: ./sintonia_webapp
|
||||||
|
target: sintonia-webapp-production
|
||||||
args:
|
args:
|
||||||
- sintonia_user=${SINTONIA_USER}
|
- sintonia_user=${SINTONIA_USER}
|
||||||
- sintonia_uid=${SINTONIA_UID}
|
- sintonia_uid=${SINTONIA_UID}
|
||||||
- sintonia_node_version=${SINTONIA_NODE_VERSION}
|
- sintonia_node_version=${SINTONIA_NODE_VERSION}
|
||||||
- sintonia_production=${SINTONIA_PRODUCTION}
|
- sintonia_config_filepath=${SINTONIA_CONFIG_FILEPATH}
|
||||||
image: sintonia-webapp
|
- libretime_config_filepath=${LIBRETIME_CONFIG_FILEPATH}
|
||||||
container_name: sintonia-webapp
|
image: sintonia-webapp-prod
|
||||||
|
container_name: sintonia-webapp-prod
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- rabbitmq
|
- rabbitmq
|
||||||
init: true
|
init: true
|
||||||
working_dir: /var/www/
|
working_dir: /var/www/sintonia_webapp
|
||||||
volumes:
|
volumes:
|
||||||
|
- ${LIBRETIME_CONFIG_FILEPATH:-./config.yml}:/etc/libretime/config.yml:ro
|
||||||
- libretime_storage:/srv/libretime
|
- libretime_storage:/srv/libretime
|
||||||
ports:
|
- libretime_assets:/var/www/html
|
||||||
- ${SINTONIA_LARAVEL_PORT}:${SINTONIA_LARAVEL_PORT}
|
|
||||||
- ${SINTONIA_VITE_PORT}:${SINTONIA_VITE_PORT}
|
|
||||||
environment:
|
|
||||||
- sintonia_laravel_port=${SINTONIA_LARAVEL_PORT}
|
|
||||||
- sintonia_vite_port=${SINTONIA_VITE_PORT}
|
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx
|
image: nginx
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
APP_NAME=Laravel
|
|
||||||
APP_ENV=local
|
|
||||||
APP_KEY=
|
|
||||||
APP_DEBUG=true
|
|
||||||
APP_URL=http://localhost
|
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
|
||||||
LOG_DEPRECATIONS_CHANNEL=null
|
|
||||||
LOG_LEVEL=debug
|
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3306
|
|
||||||
DB_DATABASE=laravel
|
|
||||||
DB_USERNAME=root
|
|
||||||
DB_PASSWORD=
|
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
|
||||||
CACHE_DRIVER=file
|
|
||||||
FILESYSTEM_DISK=local
|
|
||||||
QUEUE_CONNECTION=sync
|
|
||||||
SESSION_DRIVER=file
|
|
||||||
SESSION_LIFETIME=120
|
|
||||||
|
|
||||||
MEMCACHED_HOST=127.0.0.1
|
|
||||||
|
|
||||||
REDIS_HOST=127.0.0.1
|
|
||||||
REDIS_PASSWORD=null
|
|
||||||
REDIS_PORT=6379
|
|
||||||
|
|
||||||
MAIL_MAILER=smtp
|
|
||||||
MAIL_HOST=mailpit
|
|
||||||
MAIL_PORT=1025
|
|
||||||
MAIL_USERNAME=null
|
|
||||||
MAIL_PASSWORD=null
|
|
||||||
MAIL_ENCRYPTION=null
|
|
||||||
MAIL_FROM_ADDRESS="hello@example.com"
|
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
|
||||||
|
|
||||||
AWS_ACCESS_KEY_ID=
|
|
||||||
AWS_SECRET_ACCESS_KEY=
|
|
||||||
AWS_DEFAULT_REGION=us-east-1
|
|
||||||
AWS_BUCKET=
|
|
||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
|
||||||
|
|
||||||
PUSHER_APP_ID=
|
|
||||||
PUSHER_APP_KEY=
|
|
||||||
PUSHER_APP_SECRET=
|
|
||||||
PUSHER_HOST=
|
|
||||||
PUSHER_PORT=443
|
|
||||||
PUSHER_SCHEME=https
|
|
||||||
PUSHER_APP_CLUSTER=mt1
|
|
||||||
|
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
|
||||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
|
||||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
|
||||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
|
||||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
|
||||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check if yq is installed
|
||||||
|
if ! command -v yq >/dev/null 2>&1; then
|
||||||
|
echo "yq is not installed. Install it first (e.g., sudo apt-get install yq)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Input YAML file
|
||||||
|
YAML_FILE="$1"
|
||||||
|
|
||||||
|
# Output .env file
|
||||||
|
ENV_FILE="$2"
|
||||||
|
|
||||||
|
# Extract values from YAML using yq
|
||||||
|
DB_HOST=$(yq '.database.host // "postgres"' "$YAML_FILE")
|
||||||
|
DB_PORT=$(yq '.database.port // "5432"' "$YAML_FILE")
|
||||||
|
DB_USER=$(yq '.database.user // "libretime"' "$YAML_FILE")
|
||||||
|
DB_PASSWORD=$(yq '.database.password // "libretime"' "$YAML_FILE")
|
||||||
|
DB_DATABASE=$(yq '.database.database // "libretime"' "$YAML_FILE")
|
||||||
|
|
||||||
|
MAIL_HOST=$(yq '.email.host // "localhost"' "$YAML_FILE")
|
||||||
|
MAIL_PORT=$(yq '.email.port // "25"' "$YAML_FILE")
|
||||||
|
MAIL_USERNAME=$(yq '.email.user // ""' "$YAML_FILE")
|
||||||
|
MAIL_PASSWORD=$(yq '.email.password // ""' "$YAML_FILE")
|
||||||
|
MAIL_ENCRYPTION=$(yq '.email.encryption // ""' "$YAML_FILE")
|
||||||
|
|
||||||
|
# Function to update or add a variable in the .env file
|
||||||
|
update_env_var() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
if grep -q "^$key=" "$ENV_FILE"; then
|
||||||
|
# Update existing variable
|
||||||
|
sed -i.bak "s|^$key=.*|$key=$value|" "$ENV_FILE"
|
||||||
|
else
|
||||||
|
# Add new variable
|
||||||
|
echo "$key=$value" >> "$ENV_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create or update the .env file with extracted values
|
||||||
|
update_env_var "DB_CONNECTION" "postgres"
|
||||||
|
update_env_var "DB_HOST" "$DB_HOST"
|
||||||
|
update_env_var "DB_PORT" "$DB_PORT"
|
||||||
|
update_env_var "DB_DATABASE" "$DB_DATABASE"
|
||||||
|
update_env_var "DB_USERNAME" "$DB_USER"
|
||||||
|
update_env_var "DB_PASSWORD" "$DB_PASSWORD"
|
||||||
|
|
||||||
|
update_env_var "MAIL_MAILER" "smtp"
|
||||||
|
update_env_var "MAIL_HOST" "$MAIL_HOST"
|
||||||
|
update_env_var "MAIL_PORT" "$MAIL_PORT"
|
||||||
|
update_env_var "MAIL_USERNAME" "$MAIL_USERNAME"
|
||||||
|
update_env_var "MAIL_PASSWORD" "$MAIL_PASSWORD"
|
||||||
|
update_env_var "MAIL_ENCRYPTION" "$MAIL_ENCRYPTION"
|
||||||
|
update_env_var "MAIL_FROM_ADDRESS" "\"hello@example.com\""
|
||||||
|
update_env_var "MAIL_FROM_NAME" "${APP_NAME}"
|
||||||
|
|
||||||
|
echo ".env file has been created/updated successfully."
|
Loading…
Reference in New Issue