mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
Moved composer and yarn to entrypoint
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Wait for MySQL...
|
||||
counter=1
|
||||
while ! mysql -h mysql -ugazelle -ppassword -e "show databases;" > /dev/null 2>&1; do
|
||||
while ! mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;" > /dev/null 2>&1; do
|
||||
sleep 1
|
||||
counter=`expr $counter + 1`
|
||||
if [ $(($counter % 20)) -eq 0 ]; then
|
||||
mysql -h mysql -ugazelle -ppassword -e "show databases;"
|
||||
>&2 echo "Still waiting for MySQL (Count: ${counter})."
|
||||
counter=$((counter + 1))
|
||||
if [ $((counter % 20)) -eq 0 ]; then
|
||||
mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;"
|
||||
>&2 echo "Still waiting for MySQL (Count: $counter)."
|
||||
fi
|
||||
done
|
||||
|
||||
counter=1
|
||||
while ! curl --fail http://web > /dev/null 2>&1; do
|
||||
sleep 1
|
||||
counter=`expr $counter + 1`
|
||||
if [ $(($counter % 20)) -eq 0 ]; then
|
||||
>&2 echo "Still waiting for Web (Count: ${counter})."
|
||||
counter=$((counter + 1))
|
||||
if [ $((counter % 20)) -eq 0 ]; then
|
||||
>&2 echo "Still waiting for Web (Count: $counter)."
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -2,20 +2,24 @@
|
||||
|
||||
run_service()
|
||||
{
|
||||
service $1 start
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
service "$1" start || exit 1
|
||||
}
|
||||
|
||||
# We'll need these anyway so why not kill some time while waiting on MySQL to be ready
|
||||
if [ -n "$ENV" ] && [ "$ENV" == "prod" ]; then
|
||||
su -c 'composer --version && composer install --no-dev --optimize-autoloader --no-suggest; yarn --prod' gazelle
|
||||
else
|
||||
su -c 'composer --version && composer install; yarn' gazelle
|
||||
fi
|
||||
|
||||
# Wait for MySQL...
|
||||
counter=1
|
||||
while ! mysql -h mysql -ugazelle -ppassword -e "show databases;" > /dev/null 2>&1; do
|
||||
while ! mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;" > /dev/null 2>&1; do
|
||||
sleep 1
|
||||
counter=$((counter + 1))
|
||||
if [ $((counter % 20)) -eq 0 ]; then
|
||||
mysql -h mysql -ugazelle -ppassword -e "show databases;"
|
||||
>&2 echo "Still waiting for MySQL (Count: ${counter})."
|
||||
mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;"
|
||||
>&2 echo "Still waiting for MySQL (Count: $counter)."
|
||||
fi;
|
||||
done
|
||||
|
||||
@@ -24,9 +28,8 @@ if [ ! -f /var/www/classes/config.php ]; then
|
||||
fi
|
||||
|
||||
echo "Run migrate..."
|
||||
LOCK_MY_DATABASE=1 /var/www/vendor/bin/phinx migrate
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! LOCK_MY_DATABASE=1 /var/www/vendor/bin/phinx migrate; then
|
||||
echo "PHINX FAILED TO MIGRATE"
|
||||
exit 1
|
||||
fi
|
||||
@@ -35,8 +38,7 @@ echo -e "\n"
|
||||
|
||||
if [ ! -f /srv/gazelle.txt ]; then
|
||||
echo "Run seed:run..."
|
||||
/var/www/vendor/bin/phinx seed:run -s InitialUserSeeder
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! /var/www/vendor/bin/phinx seed:run -s InitialUserSeeder; then
|
||||
echo "PHINX FAILED TO SEED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
vendor/
|
||||
node_modules/
|
||||
Vagrantfile
|
||||
.vagrant/
|
||||
html/
|
||||
|
||||
17
Dockerfile
17
Dockerfile
@@ -1,7 +1,5 @@
|
||||
FROM debian:buster-slim
|
||||
|
||||
ARG BuildMode=dev
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
# Misc software layer
|
||||
@@ -101,21 +99,8 @@ RUN chown -R gazelle:gazelle /var/www \
|
||||
&& ln -s /etc/nginx/sites-available/gazelle.conf /etc/nginx/sites-enabled/gazelle.conf \
|
||||
&& rm -f /etc/nginx/sites-enabled/default
|
||||
|
||||
USER gazelle
|
||||
|
||||
# Build/run deps install layer
|
||||
RUN if [ "$BuildMode" = "prod" ]; then \
|
||||
composer --version && composer install --no-dev --optimize-autoloader --no-suggest; \
|
||||
yarn --prod; \
|
||||
else \
|
||||
composer --version && composer install; \
|
||||
yarn; \
|
||||
fi
|
||||
|
||||
USER root
|
||||
|
||||
EXPOSE 80/tcp
|
||||
EXPOSE 3306/tcp
|
||||
EXPOSE 34000/tcp
|
||||
|
||||
CMD ["/bin/bash", "/var/www/.docker/web/entrypoint.sh"]
|
||||
ENTRYPOINT [ "/bin/bash", "/var/www/.docker/web/entrypoint.sh" ]
|
||||
|
||||
@@ -82,10 +82,10 @@ And then:
|
||||
In the same vein, you can use `mysqldump` to perform a backup.
|
||||
|
||||
#### Production Mode (not fully baked yet)
|
||||
In order to have Docker build the container using the production mode commands
|
||||
for both Composer and NPM, run this before powering it up:
|
||||
In order to have Docker run the container using the production mode commands
|
||||
for both Composer and NPM, run this when powering it up:
|
||||
|
||||
`docker-compose build --build-arg BuildMode=prod`
|
||||
`ENV=prod docker-compose up`
|
||||
|
||||
### Vagrant (Legacy)
|
||||
This repository comes pre-setup to be run through
|
||||
|
||||
@@ -12,10 +12,9 @@ services:
|
||||
- mysql
|
||||
volumes:
|
||||
- .:/var/www
|
||||
- /var/www/vendor
|
||||
- /var/www/node_modules
|
||||
- .docker/web/nginx.conf:/etc/nginx/sites-available/gazelle.conf
|
||||
environment:
|
||||
- ENV
|
||||
# These should match what you set for your mysql container below
|
||||
- MYSQL_USER=gazelle
|
||||
- MYSQL_PASSWORD=password
|
||||
@@ -42,3 +41,7 @@ services:
|
||||
volumes:
|
||||
- ./.docker/data/sphinxsearch:/var/lib/sphinxsearch/data/
|
||||
- ./.docker/sphinxsearch/sphinx.conf:/var/lib/sphinxsearch/conf/sphinx.conf
|
||||
environment:
|
||||
# These should match what you set for your mysql container above
|
||||
- MYSQL_USER=gazelle
|
||||
- MYSQL_PASSWORD=password
|
||||
|
||||
Reference in New Issue
Block a user