Skip to content

Commit

Permalink
updates git-sync installation in init container
Browse files Browse the repository at this point in the history
  • Loading branch information
SonOfLope committed Nov 19, 2023
1 parent 2e828db commit 3c4f3a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
14 changes: 4 additions & 10 deletions grav/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,13 @@ RUN pecl install apcu \
&& pecl install yaml \
&& docker-php-ext-enable apcu yaml

# Set user to www-data
RUN chown www-data:www-data /var/www
USER www-data

# Define Grav specific version of Grav or use latest stable
ARG GRAV_VERSION=latest

# Install Git Sync plugin
RUN git clone https://github.com/getgrav/grav.git /var/www/html/grav && \
cd /var/www/html/grav && \
bin/gpm install git-sync

RUN chown -R www-data:www-data /var/www/html
# Set user to www-data
RUN chown www-data:www-data /var/www
USER www-data
RUN mkdir -p /var/www/html

# Create cron job for Grav maintenance scripts
RUN (crontab -l; echo "* * * * * cd /var/www/html;/usr/local/bin/php bin/grav scheduler 1>> /dev/null 2>&1") | crontab -
Expand Down
13 changes: 5 additions & 8 deletions grav/init-grav/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Use a base image that has necessary tools (e.g., wget, rsync)
FROM alpine:latest

# Install necessary packages
RUN apk add --no-cache wget unzip rsync
RUN apk add --no-cache wget unzip rsync git \
php php-fpm php-cli php-curl php-mbstring php-openssl php-dom php-xml php-json php-phar php-zip

# Define Grav theme/skeleton URL
ARG GRAV_SKELETON_URL=https://github.com/getgrav/grav-skeleton-gateway-site/releases/download/1.0.1/grav-skeleton-gateway-site+admin-1.0.1.zip

# Download and unzip the theme
WORKDIR /initial-content
RUN wget "$GRAV_SKELETON_URL" -O theme.zip \
&& unzip theme.zip \
&& rm theme.zip
&& rm theme.zip \
&& git clone https://github.com/getgrav/grav.git grav

# Add and prepare the script to copy content if necessary
COPY copy-theme.sh /copy-theme.sh
RUN chmod +x /copy-theme.sh
ENTRYPOINT ["/copy-theme.sh"]
ENTRYPOINT ["/copy-theme.sh"]
6 changes: 5 additions & 1 deletion grav/init-grav/copy-theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ THEMES_DIR=/var/www/html/user/themes

# Function to check if Grav is ready
is_grav_ready() {
[ -d /var/www/html/grav ]
[ -d /var/www/html ]
}

# Wait for Grav to be ready
Expand All @@ -24,8 +24,12 @@ if [ -z "$(ls -A "$THEMES_DIR")" ]; then
rsync -av /initial-content/ /var/www/html/
# Change ownership of the copied content to www-data
chown -R 33:33 /var/www/html
# Install git-sync plugin
cd /var/www/html
bin/gpm install git-sync
else
echo "Themes directory is not empty. Skipping copying initial content."
fi



0 comments on commit 3c4f3a6

Please sign in to comment.