-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates the container to separate grav cms solution from the skeleton…
… installation
- Loading branch information
Showing
6 changed files
with
143 additions
and
71 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,68 @@ | ||
name: Docker | ||
# disabled until further notice. we are currently pushing images manually | ||
# name: Docker | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*-*' | ||
# on: | ||
# push: | ||
# tags: | ||
# - 'v*.*.*-*' | ||
|
||
jobs: | ||
build-on-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check Out Repo | ||
uses: actions/checkout@v4 | ||
# jobs: | ||
# build-on-release: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Check Out Repo | ||
# uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
# - name: Set up Docker Buildx | ||
# id: buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
# - name: Login to Docker Hub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx | ||
# - name: Cache Docker layers | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: /tmp/.buildx-cache | ||
# key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
# restore-keys: ${{ runner.os }}-buildx | ||
|
||
- name: Get Tag Version | ||
id: tag | ||
run: | | ||
FULL_VERSION=${GITHUB_REF#refs/tags/} | ||
echo "Full version: $FULL_VERSION" | ||
# - name: Get Tag Version | ||
# id: tag | ||
# run: | | ||
# FULL_VERSION=${GITHUB_REF#refs/tags/} | ||
# echo "Full version: $FULL_VERSION" | ||
|
||
VERSION=${FULL_VERSION#v} | ||
VERSION=${VERSION%-grav*} | ||
echo "Version to be used: $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
# VERSION=${FULL_VERSION#v} | ||
# VERSION=${VERSION%-grav*} | ||
# echo "Version to be used: $VERSION" | ||
# echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
|
||
# Extract project name after '-' | ||
SUFFIX=${FULL_VERSION#*-} | ||
echo "Suffix: $SUFFIX" | ||
echo "PROJECT_DIR=$SUFFIX" >> $GITHUB_ENV | ||
# # Extract project name after '-' | ||
# SUFFIX=${FULL_VERSION#*-} | ||
# echo "Suffix: $SUFFIX" | ||
# echo "PROJECT_DIR=$SUFFIX" >> $GITHUB_ENV | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./${{ env.PROJECT_DIR }} | ||
file: ./${{ env.PROJECT_DIR }}/Dockerfile | ||
push: true | ||
tags: | | ||
${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ env.PROJECT_DIR }}:${{ env.VERSION }} | ||
${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ env.PROJECT_DIR }}:latest | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
# - name: Build and push | ||
# id: docker_build | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: ./${{ env.PROJECT_DIR }} | ||
# file: ./${{ env.PROJECT_DIR }}/Dockerfile | ||
# push: true | ||
# tags: | | ||
# ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ env.PROJECT_DIR }}:${{ env.VERSION }} | ||
# ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ env.PROJECT_DIR }}:latest | ||
# cache-from: type=local,src=/tmp/.buildx-cache | ||
# cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
|
||
- name: Refresh Cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
# - name: Refresh Cache | ||
# run: | | ||
# rm -rf /tmp/.buildx-cache | ||
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
|
||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} | ||
# - name: Image digest | ||
# run: echo ${{ steps.docker_build.outputs.digest }} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
version: '3.8' | ||
|
||
services: | ||
grav-init: | ||
depends_on: | ||
- grav | ||
build: | ||
context: ./init-grav | ||
dockerfile: Dockerfile | ||
container_name: grav_init | ||
volumes: | ||
- grav_data:/var/www/html | ||
|
||
grav: | ||
build: . | ||
container_name: grav_cms | ||
ports: | ||
- "8080:80" | ||
volumes: | ||
- grav_data:/var/www/html | ||
environment: | ||
- GRAV_VERSION=latest | ||
- 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 | ||
|
||
volumes: | ||
grav_data: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 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 | ||
|
||
# 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 | ||
|
||
# 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"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
# copy-theme.sh | ||
|
||
THEMES_DIR=/var/www/html/user/themes | ||
|
||
# Function to check if Grav is ready | ||
is_grav_ready() { | ||
[ -d /var/www/html/grav ] | ||
} | ||
|
||
# Wait for Grav to be ready | ||
while ! is_grav_ready; do | ||
echo "Waiting for Grav to be ready..." | ||
sleep 10 | ||
done | ||
|
||
echo "Grav is ready. Copying theme..." | ||
|
||
# Create the themes directory if it does not exist | ||
[ ! -d "$THEMES_DIR" ] && mkdir -p "$THEMES_DIR" | ||
|
||
# Use rsync to copy the initial content | ||
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 | ||
else | ||
echo "Themes directory is not empty. Skipping copying initial content." | ||
fi | ||
|
||
|