Skip to content

Commit

Permalink
Upstream update (#10)
Browse files Browse the repository at this point in the history
* Upstream update
* version bump
* Dockerfile refactor
* code cleaning
* updated CI to use the latest SDK
* fixed formatting
* license update
* misc changes and updates
* Do prerelease by default in CI
* Disable update check by default
* Hide updates and database warnings from the user
* Fix delimiter
  • Loading branch information
k0gen authored Oct 2, 2023
1 parent e3bc695 commit b451990
Show file tree
Hide file tree
Showing 16 changed files with 503 additions and 268 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/buildService.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Build Service
on:
workflow_dispatch:
pull_request:
paths-ignore: ['*.md']
branches: ['master', 'next']
paths-ignore: ["*.md"]
branches: ["master", "next"]
push:
paths-ignore: ['*.md']
branches: ['master', 'next']
paths-ignore: ["*.md"]
branches: ["master", "next"]

jobs:
BuildPackage:
Expand All @@ -22,7 +22,7 @@ jobs:
with:
toolchain: stable
- name: Get StartOS Hash
run: echo "STARTOSHASH=$(git ls-remote https://github.com/Start9Labs/start-os --branch latest | awk '{ print $1}')" >> $GITHUB_ENV
run: echo "STARTOSHASH=$(git ls-remote https://github.com/Start9Labs/start-os --branch sdk | awk '{ print $1}')" >> $GITHUB_ENV
- name: Cache Packages
uses: buildjet/cache@v3
id: packageCache
Expand All @@ -44,7 +44,7 @@ jobs:
id: packageManager
if: steps.packageCache.outputs.cache-hit != 'true'
run: |
cd ~/ && git clone https://github.com/Start9Labs/start-os.git --branch latest;
cd ~/ && git clone https://github.com/Start9Labs/start-os.git --branch sdk;
cd start-os;
git submodule update --init --recursive
cd backend;
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Build the service package
run: |
git submodule update --init --recursive
embassy-sdk init
start-sdk init
make
mv ghost*s9pk ~/
- name: Upload .s9pk
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/releaseService.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- 'v*.*'
- "v*.*"

jobs:
ReleasePackage:
Expand All @@ -19,7 +19,7 @@ jobs:
with:
toolchain: stable
- name: Get StartOS Hash
run: echo "STARTOSHASH=$(git ls-remote https://github.com/Start9Labs/start-os --branch latest | awk '{ print $1}')" >> $GITHUB_ENV
run: echo "STARTOSHASH=$(git ls-remote https://github.com/Start9Labs/start-os --branch sdk | awk '{ print $1}')" >> $GITHUB_ENV
- name: Cache Packages
uses: buildjet/cache@v3
id: packageCache
Expand All @@ -41,7 +41,7 @@ jobs:
id: packageManager
if: steps.packageCache.outputs.cache-hit != 'true'
run: |
cd ~/ && git clone https://github.com/Start9Labs/start-os.git --branch latest;
cd ~/ && git clone https://github.com/Start9Labs/start-os.git --branch sdk;
cd start-os;
git submodule update --init --recursive
cd backend;
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Build the service package
run: |
git submodule update --init --recursive
embassy-sdk init
start-sdk init
make
- name: Generate sha256 checksum
run: |
Expand All @@ -60,13 +60,18 @@ jobs:
run: |
echo "## What's Changed" > change-log.txt
yq e '.release-notes' manifest.yaml >> change-log.txt
echo "## SHA256 Hash" >> change-log.txt
echo '```' >> change-log.txt
sha256sum ghost.s9pk >> change-log.txt
echo '```' >> change-log.txt
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: Ghost ${{ github.ref_name }}
prerelease: true
body_path: change-log.txt
files: |
ghost.s9pk
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ghost.s9pk
image.tar
scripts/embassy.js
docker-images
.DS_Store
Expand Down
120 changes: 6 additions & 114 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,133 +1,25 @@
FROM node:16-bullseye-slim
FROM ghost:5.65.1

# grab gosu for easy step-down from root
# https://github.com/tianon/gosu/releases
ENV GOSU_VERSION 1.16
# grab yq for easy parsing
# https://github.com/mikefarah/yq/releases
ENV YQ_VERSION v4.25.1
RUN set -eux; \
# save list of currently installed packages for later so we can clean up
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get install -y --no-install-recommends ca-certificates gnupg wget; \
rm -rf /var/lib/apt/lists/*; \
\
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/yq_linux_$dpkgArch"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
chmod +x /usr/local/bin/yq; \
\
# verify the signature
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
\
# clean up fetch dependencies
apt-mark auto '.*' > /dev/null; \
apt-get remove --purge -y ca-certificates gnupg wget; \
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
chmod +x /usr/local/bin/gosu; \
# verify that the binary works
gosu --version; \
gosu nobody true

ENV NODE_ENV production
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;

ENV GHOST_CLI_VERSION 1.24.2
RUN set -eux; \
npm install -g "ghost-cli@$GHOST_CLI_VERSION"; \
npm cache clean --force

ENV GHOST_INSTALL /var/lib/ghost
ENV GHOST_CONTENT /var/lib/ghost/content

ENV GHOST_VERSION 5.54.0

RUN set -eux; \
mkdir -p "$GHOST_INSTALL"; \
chown node:node "$GHOST_INSTALL"; \
\
savedAptMark="$(apt-mark showmanual)"; \
aptPurge=; \
\
installCmd='gosu node ghost install "$GHOST_VERSION" --db mysql --dbhost mysql --no-prompt --no-stack --no-setup --dir "$GHOST_INSTALL"'; \
if ! eval "$installCmd"; then \
aptPurge=1; \
apt-get update; \
apt-get install -y --no-install-recommends g++ make python3; \
eval "$installCmd"; \
fi; \
\
# Tell Ghost to listen on all ips and not prompt for additional configuration
cd "$GHOST_INSTALL"; \
gosu node ghost config --no-prompt --ip '::' --port 2368 --url 'http://localhost:2368'; \
gosu node ghost config paths.contentPath "$GHOST_CONTENT"; \
\
# make a config.json symlink for NODE_ENV=development (and sanity check that it's correct)
gosu node ln -s config.production.json "$GHOST_INSTALL/config.development.json"; \
readlink -f "$GHOST_INSTALL/config.development.json"; \
\
# need to save initial content for pre-seeding empty volumes
mv "$GHOST_CONTENT" "$GHOST_INSTALL/content.orig"; \
mkdir -p "$GHOST_CONTENT"; \
chown node:node "$GHOST_CONTENT"; \
chmod 1777 "$GHOST_CONTENT"; \
\
# force install a few extra packages manually since they're "optional" dependencies
# (which means that if it fails to install, like on ARM/ppc64le/s390x, the failure will be silently ignored and thus turn into a runtime error instead)
# see https://github.com/TryGhost/Ghost/pull/7677 for more details
cd "$GHOST_INSTALL/current"; \
# scrape the expected versions directly from Ghost/dependencies
packages="$(node -p ' \
var ghost = require("./package.json"); \
var transform = require("./node_modules/@tryghost/image-transform/package.json"); \
[ \
"sharp@" + transform.optionalDependencies["sharp"], \
].join(" ") \
')"; \
if echo "$packages" | grep 'undefined'; then exit 1; fi; \
for package in $packages; do \
installCmd='gosu node yarn add "$package" --force'; \
if ! eval "$installCmd"; then \
# must be some non-amd64 architecture pre-built binaries aren't published for, so let's install some build deps and do-it-all-over-again
aptPurge=1; \
apt-get update; \
apt-get install -y --no-install-recommends g++ make python3; \
case "$package" in \
# TODO sharp@*) apt-get install -y --no-install-recommends libvips-dev ;; \
sharp@*) echo >&2 "sorry: libvips 8.10 in Debian bullseye is not new enough (8.12.2+) for sharp 0.30 😞"; continue ;; \
esac; \
\
eval "$installCmd --build-from-source"; \
fi; \
done; \
\
if [ -n "$aptPurge" ]; then \
apt-mark showmanual | xargs apt-mark auto > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
apt-get purge -y --auto-remove; \
rm -rf /var/lib/apt/lists/*; \
fi; \
\
gosu node yarn cache clean; \
gosu node npm cache clean --force; \
npm cache clean --force; \
rm -rv /tmp/yarn* /tmp/v8*
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends mariadb-server mariadb-client; \
rm /etc/mysql/mariadb.conf.d/50-server.cnf; \
rm -rf /var/lib/apt/lists/*;

WORKDIR $GHOST_INSTALL
VOLUME $GHOST_CONTENT

COPY start-ghost.sh /usr/local/bin
COPY docker_entrypoint.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/*.sh
COPY --chmod=a+x docker_entrypoint.sh /usr/local/bin
COPY scripts/local /var/lib/ghost/current/core/built/admin/assets/local
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2022 Ghost Foundation
Copyright (c) 2023 Start9

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ all: verify

install:
ifeq (,$(wildcard ~/.embassy/config.yaml))
@echo; echo "You must define \"host: http://embassy-server-name.local\" in ~/.embassy/config.yaml config file first"; echo
@echo; echo "You must define \"host: http://server-name.local\" in ~/.embassy/config.yaml config file first"; echo
else
embassy-cli package install $(PKG_ID).s9pk
start-cli package install $(PKG_ID).s9pk
endif

arm:
Expand All @@ -23,7 +23,7 @@ x86:
ARCH=x86_64 $(MAKE)

verify: $(PKG_ID).s9pk
@embassy-sdk verify s9pk $(PKG_ID).s9pk
@start-sdk verify s9pk $(PKG_ID).s9pk
@echo " Done!"
@echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready"

Expand All @@ -43,13 +43,13 @@ update:

$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar
ifeq ($(ARCH),aarch64)
@echo "embassy-sdk: Preparing aarch64 package ..."
@echo "start-sdk: Preparing aarch64 package ..."
else ifeq ($(ARCH),x86_64)
@echo "embassy-sdk: Preparing x86_64 package ..."
@echo "start-sdk: Preparing x86_64 package ..."
else
@echo "embassy-sdk: Preparing Universal Package ..."
@echo "start-sdk: Preparing Universal Package ..."
endif
@embassy-sdk pack
@start-sdk pack

docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh
ifeq ($(ARCH),x86_64)
Expand Down
Loading

0 comments on commit b451990

Please sign in to comment.