-
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.
Merge branch 'demo-bog' into release
- Loading branch information
Showing
24 changed files
with
416 additions
and
582 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: FE Build | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
publisher_payload: | ||
description: Publisher payload | ||
required: true | ||
env: | ||
description: Environment | ||
required: true | ||
|
||
run-name: 'FE Build [env: ${{ inputs.env }}]' | ||
|
||
concurrency: | ||
group: fe_build_${{ inputs.env }} | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- name: TurboRepo local server | ||
uses: felixmosh/turborepo-gh-artifacts@v2 | ||
with: | ||
server-token: 'local' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Prepare | ||
run: SKIP_DRUPAL_INSTALL=1 pnpm turbo:prep | ||
env: | ||
TURBO_API: 'http://127.0.0.1:9080' | ||
TURBO_TOKEN: 'local' | ||
TURBO_TEAM: 'local' | ||
|
||
- name: Publisher | ||
uses: AmazeeLabs/publisher-action@4371b4a90a9fe2c86248e76c0f428e39abf6b610 | ||
with: | ||
success_env_var_name: BUILD_IS_SUCCESSFUL | ||
cache_paths: | | ||
apps/website/.cache | ||
apps/website/public | ||
cache_key: 'fe-build-${{ inputs.env }}' | ||
|
||
- name: Build & deploy | ||
run: | | ||
set -ex | ||
cd apps/website | ||
# Build | ||
if test -d public; then | ||
echo "Single build" | ||
pnpm build:gatsby | ||
else | ||
echo "Double build" | ||
# To mitigate Gatsby bug: | ||
# The first incremental build rewrites compilation hashes even if | ||
# there are no content changes. | ||
pnpm build:gatsby | ||
pnpm build:gatsby | ||
fi | ||
# Deploy | ||
pnpm netlify env:set AWS_LAMBDA_JS_RUNTIME nodejs18.x | ||
pnpm netlify env:set DRUPAL_EXTERNAL_URL $DRUPAL_EXTERNAL_URL | ||
pnpm netlify deploy --cwd=. --dir=apps/website/public --prodIfUnlocked | ||
# Report success to Publisher | ||
echo "BUILD_IS_SUCCESSFUL=1" >> $GITHUB_ENV | ||
env: | ||
TURBO_API: 'http://127.0.0.1:9080' | ||
TURBO_TOKEN: 'local' | ||
TURBO_TEAM: 'local' |
4 changes: 2 additions & 2 deletions
4
.idea/runConfigurations/Website_Dev.xml → .idea/runConfigurations/Publisher_Dev.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...Configurations/Website_Open_Publisher.xml → .idea/runConfigurations/Publisher_Open.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.idea/runConfigurations/website__dev.xml → .idea/runConfigurations/publisher__dev.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.idea/runConfigurations/website__open.xml → .idea/runConfigurations/publisher__open.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -49,7 +49,7 @@ RUN --mount=type=cache,target=/tmp/cache pnpm i && \ | |
|
||
# Deploy apps. | ||
RUN --mount=type=cache,target=/tmp/cache pnpm deploy --filter "@custom/cms" /tmp/.deploy/cms --prod | ||
RUN --mount=type=cache,target=/tmp/cache pnpm deploy --filter "@custom/website" /tmp/.deploy/website --prod | ||
RUN --mount=type=cache,target=/tmp/cache pnpm deploy --filter "@custom/publisher" /tmp/.deploy/publisher --prod | ||
RUN --mount=type=cache,target=/tmp/cache pnpm deploy --filter "@custom/preview" /tmp/.deploy/preview --prod | ||
|
||
# ==================================================================================================== | ||
|
@@ -98,54 +98,22 @@ ENV WEBROOT=web | |
# PREVIEW IMAGE | ||
# ==================================================================================================== | ||
|
||
FROM uselagoon/node-18:23.12.0 as preview | ||
FROM uselagoon/node-18 as preview | ||
|
||
RUN npm install -g pnpm@8.6.0 | ||
RUN npm install -g pnpm@8.15.9 | ||
COPY --from=builder /tmp/.deploy/preview /app | ||
CMD pnpm start | ||
|
||
# ==================================================================================================== | ||
# PUBLISHER IMAGE | ||
# ==================================================================================================== | ||
|
||
FROM uselagoon/node-18:23.12.0 as publisher | ||
|
||
# DENO INSTALL | ||
ENV ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" | ||
ENV ALPINE_GLIBC_PACKAGE_VERSION="2.34-r0" | ||
ENV ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" | ||
ENV ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" | ||
ENV ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" | ||
|
||
RUN echo "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" | ||
|
||
RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \ | ||
echo "-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m 1QIDAQAB -----END PUBLIC KEY-----" | sed 's/ */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" && \ | ||
wget "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ | ||
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ | ||
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ | ||
mv /etc/nsswitch.conf /etc/nsswitch.conf.bak && \ | ||
apk add --no-cache --force-overwrite \ | ||
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \ | ||
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \ | ||
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \ | ||
mv /etc/nsswitch.conf.bak /etc/nsswitch.conf && \ | ||
rm "/etc/apk/keys/sgerrand.rsa.pub" && \ | ||
(/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true) && \ | ||
echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \ | ||
apk del glibc-i18n && \ | ||
apk del .build-dependencies && \ | ||
rm "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" | ||
|
||
RUN apk add --no-cache sqlite curl | ||
|
||
RUN npm install -g [email protected] | ||
ENV DENO_INSTALL="/home/.deno" | ||
RUN if [ "$(uname -m)" != "aarch64" ]; then curl -fsSL https://deno.land/x/install/install.sh | sh; else echo "Skipping Deno installation"; fi | ||
RUN if [ "$(uname -m)" != "aarch64" ]; then ln -s /home/.deno/bin/deno /usr/local/bin/deno; fi | ||
|
||
COPY --from=builder /tmp/.deploy/website /app | ||
|
||
RUN mkdir -p /home/.cache/deno/gen && chmod -R 777 /home/.cache/deno | ||
FROM uselagoon/node-18 as publisher | ||
|
||
RUN apk add --no-cache sqlite curl github-cli | ||
|
||
RUN npm install -g [email protected] | ||
|
||
COPY --from=builder /tmp/.deploy/publisher /app | ||
|
||
CMD pnpm publisher |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.cache |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
{ | ||
"name": "@custom/publisher", | ||
"private": true, | ||
"dependencies": { | ||
"@amazeelabs/publisher": "^2.5.5" | ||
}, | ||
"scripts": { | ||
"test:static": "tsc --noEmit && eslint '**/*.{ts,tsx,js,jsx}' --ignore-path='./.gitignore'", | ||
"dev": "cd ../website && pnpm clean && cd - && publisher", | ||
"open": "open http://127.0.0.1:8000/___status/" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18" | ||
} | ||
} |
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,83 @@ | ||
import { defineConfig } from '@amazeelabs/publisher'; | ||
|
||
const isLagoon = !!process.env.LAGOON; | ||
|
||
const base = { | ||
databaseUrl: '/tmp/publisher.sqlite', | ||
publisherPort: isLagoon ? 3000 : 8000, | ||
oAuth2: isLagoon | ||
? { | ||
clientId: process.env.PUBLISHER_OAUTH2_CLIENT_ID || 'publisher', | ||
clientSecret: process.env.PUBLISHER_OAUTH2_CLIENT_SECRET || 'publisher', | ||
sessionSecret: process.env.PUBLISHER_OAUTH2_SESSION_SECRET || 'banana', | ||
tokenHost: | ||
process.env.PUBLISHER_OAUTH2_TOKEN_HOST || 'http://127.0.0.1:8888', | ||
environmentType: | ||
process.env.PUBLISHER_OAUTH2_ENVIRONMENT_TYPE || 'development', | ||
scope: 'publisher', | ||
tokenPath: '/oauth/token', | ||
authorizePath: '/oauth/authorize?response_type=code', | ||
grantType: 0, | ||
} | ||
: undefined, | ||
}; | ||
|
||
export default defineConfig( | ||
isLagoon | ||
? { | ||
...base, | ||
mode: 'github-workflow', | ||
publisherBaseUrl: `https://${process.env.SERVICE_NAME}.${process.env.LAGOON_ENVIRONMENT}.${process.env.LAGOON_PROJECT}.${process.env.LAGOON_KUBERNETES}`, | ||
workflow: 'fe_build.yml', | ||
repo: 'AmazeeLabs/silverback-template', | ||
ref: process.env.LAGOON_GIT_BRANCH!, | ||
environment: process.env.LAGOON_GIT_BRANCH!, | ||
environmentVariables: githubEnvVars(), | ||
inputs: { | ||
env: process.env.LAGOON_GIT_BRANCH!, | ||
}, | ||
workflowTimeout: 1000 * 60 * 30, | ||
} | ||
: { | ||
...base, | ||
mode: 'local', | ||
commands: { | ||
build: { | ||
command: | ||
'cd ../website && DRUPAL_EXTERNAL_URL=http://127.0.0.1:8888 pnpm build:gatsby', | ||
}, | ||
clean: 'pnpm clean', | ||
serve: { | ||
command: | ||
'cd ../website && pnpm netlify dev --cwd=. --dir=public --port=7999', | ||
readyPattern: 'Server now ready', | ||
readyTimeout: 1000 * 60, | ||
port: 7999, | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
function githubEnvVars(): Record<string, string> { | ||
return Object.fromEntries( | ||
[ | ||
'DRUPAL_INTERNAL_URL', | ||
'DRUPAL_EXTERNAL_URL', | ||
'NETLIFY_URL', | ||
'NETLIFY_SITE_ID', | ||
'NETLIFY_AUTH_TOKEN', | ||
'PUBLISHER_SKIP_AUTHENTICATION', | ||
'PUBLISHER_OAUTH2_CLIENT_SECRET', | ||
'PUBLISHER_OAUTH2_CLIENT_ID', | ||
'PUBLISHER_OAUTH2_SESSION_SECRET', | ||
'PUBLISHER_OAUTH2_ENVIRONMENT_TYPE', | ||
'PUBLISHER_OAUTH2_TOKEN_HOST', | ||
].map((name) => { | ||
if (name === 'DRUPAL_INTERNAL_URL') { | ||
// No internal URLs when building on Github. | ||
return ['DRUPAL_INTERNAL_URL', process.env.DRUPAL_EXTERNAL_URL || '']; | ||
} | ||
return [name, process.env[name] || '']; | ||
}), | ||
); | ||
} |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node" | ||
}, | ||
"exclude": ["node_modules"] | ||
} |
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,8 @@ | ||
{ | ||
"extends": ["//"], | ||
"tasks": { | ||
"test:static": { | ||
"inputs": ["publisher.config.ts", "tsconfig.json"] | ||
} | ||
} | ||
} |
Oops, something went wrong.