Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker migration #603

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN apk add php8-zip \
php8-fileinfo \
php8-simplexml php8-xml php8-xmlreader php8-xmlwriter \
php8-tokenizer

RUN apk update && \
apk add --no-cache \
libzip-dev \
Expand All @@ -45,30 +45,32 @@ RUN curl -sS https://getcomposer.org/installer | php \
COPY . /var/www/mercator
WORKDIR /var/www/mercator

# the sqlite file must exist
# RUN touch ${DB_DATABASE}

# add mercator:www user
RUN addgroup --g 1000 -S www && \
adduser -u 1000 -S mercator -G www && \
chown -R mercator:www /var/www /var/lib/nginx /var/log/nginx /etc/nginx/http.d

# COPY nginx.conf /etc/nginx/http.d/mercator.conf
# RUN chown -R mercator:www
# RUN chown -R mercator:www

RUN cp docker/nginx.conf /etc/nginx/http.d/default.conf
RUN cp docker/supervisord.conf /etc/supervisord.conf
RUN chown -R mercator:www /etc/nginx/http.d/default.conf
RUN chown -R mercator:www /etc/supervisord.conf


USER mercator:www

# Install mercator deps
RUN set -ex ; \
composer -n validate --strict ; \
composer -n install --no-scripts --ignore-platform-reqs --no-dev

# Publish Laravel Vendor resources
RUN php artisan vendor:publish --all

# Install passport
RUN php artisan passport:install

EXPOSE 8000

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
8 changes: 2 additions & 6 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ nodaemon=true

[program:migrate]
command=/bin/sh -c '
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate --force;
if [ ! -s ${DB_DATABASE} ];
then
touch ${DB_DATABASE} && chmod a+x ${DB_DATABASE} &&
(php artisan migrate --force) &&
(php artisan db:seed --force && php artisan passport:install);
else
php artisan migrate;
php artisan db:seed --force;
fi;
touch /tmp/migrated'
autorestart=false
Expand Down
Loading