Skip to content

Commit

Permalink
Several minor fixes (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngeorger authored Apr 1, 2024
2 parents 89b4500 + 7c2f86a commit 055d3d4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 35 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ kubernetes-deployment/config.json
dockermount/

test/
**.local
**.local.**
ghost-upstream/
content/
config.production.json
Expand All @@ -114,3 +114,6 @@ ghost-local.db
.monokle
.monokle
docker-compose.yml
trustr-production-promote.yaml
trustr-staging-build-monorepo.yaml
trustr-staging-build-not-monorepo.yaml
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ FROM node:hydrogen-bookworm-slim AS build-env
ENV NODE_ENV production

# Install the latest version of Ghost CLI globally and clean the npm cache
RUN npm install -g "ghost-cli@latest" && \
npm cache clean --force
RUN npm install -g "ghost-cli@latest"

# Define the GHOST_VERSION build argument and set it as an environment variable
ARG GHOST_VERSION
Expand All @@ -23,11 +22,11 @@ ENV GHOST_CONTENT_ORIGINAL /var/lib/ghost/content.orig

# Create the Ghost installation directory and set the owner to the "node" user
RUN mkdir -pv "$GHOST_INSTALL" && \
chown node:node "$GHOST_INSTALL"
chown node:node "$GHOST_INSTALL"

# Switch to the "node" user and set the working directory to the home directory
USER node
WORKDIR /home/node
# WORKDIR /home/node

# Install Ghost with the specified version, using MySQL as the database, and configure it without prompts, stack traces, setup, and in the specified installation directory
RUN ghost install $GHOST_VERSION --db mysql --dbhost mysql --no-prompt --no-stack --no-setup --dir $GHOST_INSTALL
Expand Down
4 changes: 2 additions & 2 deletions deploy/02-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
app.kubernetes.io/component: frontend
app.kubernetes.io/part-of: ghost-k8s
spec:
storageClassName: longhorn-rwx # Change this to your storageClassName
storageClassName: longhorn-tmp # Change this to your storageClassName
volumeMode: Filesystem
accessModes:
- ReadWriteMany # Change this to your accessModes if needed
Expand All @@ -33,7 +33,7 @@ metadata:
app.kubernetes.io/part-of: ghost-k8s

spec:
storageClassName: longhorn-rwx # Change this to your storageClassName
storageClassName: longhorn-tmp # Change this to your storageClassName
volumeMode: Filesystem
accessModes:
- ReadWriteMany # Change this to ReadWriteOnce if you are not using a distributed storage system
Expand Down
12 changes: 6 additions & 6 deletions deploy/03-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ metadata:
name: service-ghost-k8s
namespace: ghost-k8s
labels:
app: service-ghost-k8s
app.kubernetes.io/name: service-ghost-k8s
app: ghost-k8s
app.kubernetes.io/name: ghost-k8s
app.kubernetes.io/instance: ghost-k8s
app.kubernetes.io/version: "5.8"
app.kubernetes.io/component: service
app.kubernetes.io/component: service-ghost
app.kubernetes.io/part-of: ghost-k8s

spec:
Expand All @@ -29,11 +29,11 @@ metadata:
name: service-mysql-ghost-k8s
namespace: ghost-k8s
labels:
app: service-mysql-ghost-k8s
app.kubernetes.io/name: service-mysql-ghost-k8s
app: mysql-ghost-k8s
app.kubernetes.io/name: mysql-ghost-k8s
app.kubernetes.io/instance: ghost-k8s
app.kubernetes.io/version: "5.8"
app.kubernetes.io/component: database
app.kubernetes.io/component: service
app.kubernetes.io/part-of: ghost-k8s
spec:
ports:
Expand Down
45 changes: 31 additions & 14 deletions deploy/05-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ spec:
labels:
app: mysql-ghost-k8s
app.kubernetes.io/name: mysql-ghost-k8s
app.kubernetes.io/instance: ghost-k8s
app.kubernetes.io/version: "5.8"
app.kubernetes.io/component: database
annotations:
container.apparmor.security.beta.kubernetes.io/mysql-ghost-k8s: runtime/default
spec:
Expand All @@ -41,19 +38,35 @@ spec:
- -c
- |
set -ex
chown -R 999:999 /mnt/mysql || true
echo 'Changing ownership of mysql mount directory to 999:999'
chown -R 999:999 /mnt/mysql || echo 'Error changing ownership of mysql mount directory to 999:999' && true
echo 'Changing ownership of tmp mount directory to 999:999'
chown -R 999:999 /mnt/tmp || echo 'Error changing ownership of tmp mount directory to 999:999' && true
echo 'Changing ownership of socket mount directory to 999:999'
chown -R 999:999 /mnt/var/run/mysqld || echo 'Error changing ownership of socket mount directory to 999:999' && true
exit 0
volumeMounts:
- name: mysql-ghost-k8s-volume
mountPath: /mnt/mysql
subPath: mysql-empty-dir

- name: mysql-ghost-k8s-tmp
mountPath: /mnt/tmp
readOnly: false

- name: mysql-ghost-k8s-socket
mountPath: /mnt/var/run/mysqld
readOnly: false

resources:
requests:
memory: 100Mi
cpu: 100m
memory: 400Mi
cpu: 300m
limits:
memory: 200Mi
cpu: 200m

memory: 1000Mi # You c
cpu: 1000m

containers:
- name: mysql-ghost-k8s
Expand All @@ -65,17 +78,17 @@ spec:
runAsUser: 999

image: docker.io/mysql:8.2
imagePullPolicy: IfNotPresent
imagePullPolicy: IfNotPresent # You can change this value according to your needs
envFrom:
- secretRef:
name: mysql-ghost-k8s
resources:
requests:
memory: 200Mi
cpu: 100m
memory: 400Mi
cpu: 300m
limits:
memory: 1Gi
cpu: 1000m
memory: 1Gi # You can change this value according to your needs
cpu: 1000m # You can change this value according to your needs
ports:
- containerPort: 3306
protocol: TCP
Expand All @@ -84,13 +97,16 @@ spec:
- name: mysql-ghost-k8s-volume
mountPath: /var/lib/mysql
subPath: mysql-empty-dir

- name: mysql-ghost-k8s-tmp
mountPath: /tmp
readOnly: false

- name: mysql-ghost-k8s-socket
mountPath: /var/run/mysqld
readOnly: false
automountServiceAccountToken: false

# Optional: Uncomment the following to specify node selectors
# affinity:
# nodeAffinity:
Expand All @@ -105,6 +121,7 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault

volumes:
- name: mysql-ghost-k8s-volume
persistentVolumeClaim:
Expand Down
19 changes: 11 additions & 8 deletions deploy/06-ghost-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,30 @@ spec:
runAsNonRoot: false
resources:
limits:
cpu: 500m
memory: 256Mi
cpu: 1000m
memory: 1000Mi
requests:
cpu: 100m
memory: 128Mi
command:
- /bin/bash
- '-c'
- |
set -e
set -ex
# Check if $GHOST_CONTENT/themes/source exists
if [ ! -d "$GHOST_CONTENT/themes/source" ]; then
# Clone the repository if the directory doesn't exist
git clone https://github.com/TryGhost/Source.git $GHOST_CONTENT/themes/source --single-branch --branch=main --depth=1
echo "Cloned Source theme"
# Remove gitconfig file and gitcredentials file.
rm -f $GHOST_CONTENT/themes/source/.gitconfig $GHOST_CONTENT/themes/source/.git-credentials || true
else
# If the directory exists, cd into it and pull the latest changes
cd $GHOST_CONTENT/themes/source
git config --global --add safe.directory $PWD
git pull origin main
echo "Pulled latest changes from Source theme"
# If the directory exists, recursively delete it.
rm -rf $GHOST_CONTENT/themes/source
# Clone the repository
git clone https://github.com/TryGhost/Source.git $GHOST_CONTENT/themes/source --single-branch --branch=main --depth=1
# Remove gitconfig file and gitcredentials file.
rm -f $GHOST_CONTENT/themes/source/.gitconfig $GHOST_CONTENT/themes/source/.git-credentials || true
fi
chown -Rf 1000:1000 $GHOST_CONTENT || true
echo "Assured ownership of the ghost installation"
Expand Down

0 comments on commit 055d3d4

Please sign in to comment.