-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
421 changed files
with
8,908 additions
and
10,942 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ RUN apt-get update && \ | |
# Base DevContainer: for use in a Dev Container where your local code is mounted into the container | ||
### Adding code and installing dependencies gets overridden by your local code/dependencies, so this is done in onCreateCommand | ||
FROM base AS base-devcontainer | ||
ARG WORKDIR=/home/ghost | ||
# Install Stripe CLI, zsh, playwright | ||
RUN curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | tee /usr/share/keyrings/stripe.gpg && \ | ||
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | tee -a /etc/apt/sources.list.d/stripe.list && \ | ||
|
@@ -28,10 +29,11 @@ RUN curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/publ | |
npx -y [email protected] install --with-deps | ||
|
||
ENV NX_DAEMON=true | ||
ENV YARN_CACHE_FOLDER=/workspaces/ghost/.yarncache | ||
ENV YARN_CACHE_FOLDER=$WORKDIR/.yarncache | ||
|
||
EXPOSE 2368 | ||
EXPOSE 4200 | ||
EXPOSE 4201 | ||
EXPOSE 4173 | ||
EXPOSE 41730 | ||
EXPOSE 4175 | ||
|
@@ -47,21 +49,13 @@ EXPOSE 7174 | |
### This is a full devcontainer with all the code and dependencies installed | ||
### Useful in an environment like Github Codespaces where you don't mount your local code into the container | ||
FROM base-devcontainer AS full-devcontainer | ||
ARG WORKDIR=/home/ghost | ||
WORKDIR $WORKDIR | ||
COPY ../../ . | ||
COPY . . | ||
RUN yarn install --frozen-lockfile --prefer-offline --cache-folder $YARN_CACHE_FOLDER | ||
|
||
# Development Stage: alternative entrypoint for development with some caching optimizations | ||
FROM base-devcontainer AS development | ||
|
||
ARG WORKDIR=/home/ghost | ||
WORKDIR $WORKDIR | ||
|
||
COPY ../../ . | ||
|
||
RUN yarn install --frozen-lockfile --prefer-offline --cache-folder $YARN_CACHE_FOLDER && \ | ||
cp -r .yarncache .yarncachecopy && \ | ||
rm -Rf .yarncachecopy/.tmp && \ | ||
yarn cache clean | ||
|
||
ENTRYPOINT ["./.devcontainer/.docker/development.entrypoint.sh"] | ||
ENTRYPOINT ["/home/ghost/.docker/development.entrypoint.sh"] | ||
CMD ["yarn", "dev"] |
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 @@ | ||
#!/bin/bash | ||
|
||
# Mounting local code into the container overwrites the `node_modules` directories | ||
# so we need to install dependencies again | ||
yarn install --frozen-lockfile --prefer-offline | ||
|
||
yarn nx run-many -t build:ts | ||
|
||
# Execute the CMD | ||
exec "$@" |
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,100 @@ | ||
const path = require('path'); | ||
const fs = require('fs').promises; | ||
const {spawn} = require('child_process'); | ||
|
||
/** | ||
* Run a command and stream output to the console | ||
* | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {object} options | ||
*/ | ||
async function runAndStream(command, args, options) { | ||
return new Promise((resolve, reject) => { | ||
const child = spawn(command, args, { | ||
stdio: 'inherit', | ||
...options | ||
}); | ||
|
||
child.on('close', (code) => { | ||
if (code === 0) { | ||
resolve(code); | ||
} else { | ||
reject(new Error(`'${command} ${args.join(' ')}' exited with code ${code}`)); | ||
} | ||
}); | ||
|
||
}); | ||
} | ||
|
||
/** | ||
* Removes node dependencies and cleans up local caches | ||
*/ | ||
function clean() { | ||
require('./clean'); | ||
} | ||
|
||
/** | ||
* Adjust config.local.json for Docker Compose setup | ||
*/ | ||
async function adjustConfig() { | ||
console.log('Adjusting configuration...'); | ||
const coreFolder = path.join(__dirname, '../../ghost/core'); | ||
const currentConfigPath = path.join(coreFolder, 'config.local.json'); | ||
let currentConfig; | ||
try { | ||
currentConfig = require(currentConfigPath); | ||
} catch (err) { | ||
currentConfig = {}; | ||
} | ||
|
||
currentConfig.database = { | ||
client: 'mysql', | ||
docker: true, | ||
connection: { | ||
host: 'mysql', | ||
user: 'root', | ||
password: 'root', | ||
database: 'ghost' | ||
} | ||
}; | ||
|
||
currentConfig.adapters = { | ||
...currentConfig.adapters, | ||
Redis: { | ||
host: 'redis', | ||
port: 6379 | ||
} | ||
}; | ||
|
||
currentConfig.server = { | ||
...currentConfig.server, | ||
host: '0.0.0.0', | ||
port: 2368 | ||
}; | ||
|
||
try { | ||
await fs.writeFile(currentConfigPath, JSON.stringify(currentConfig, null, 4)); | ||
} catch (err) { | ||
console.error('Failed to write config.local.json', err); | ||
console.log(`Please add the following to config.local.json:\n`, JSON.stringify(currentConfig, null, 4)); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
async function buildContainer() { | ||
console.log('Building container...'); | ||
await runAndStream('docker-compose', ['build'], {}); | ||
} | ||
|
||
async function runMigrations() { | ||
console.log('Running migrations...'); | ||
await runAndStream('docker-compose', ['run', '--rm', '-w', '/home/ghost/ghost/core', 'ghost', 'yarn', 'knex-migrator', 'init'], {cwd: path.join(__dirname, '../../')}); | ||
} | ||
|
||
(async () => { | ||
clean(); | ||
await adjustConfig(); | ||
await buildContainer(); | ||
await runMigrations(); | ||
})(); |
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 |
---|---|---|
|
@@ -850,7 +850,7 @@ describe('ActivityPubAPI', function () { | |
}, | ||
[`https://activitypub.api/.ghost/activitypub/actions/search?query=${encodeURIComponent(handle)}`]: { | ||
response: JSONResponse({ | ||
profiles: [ | ||
accounts: [ | ||
{ | ||
handle, | ||
name: 'Foo Bar' | ||
|
@@ -869,7 +869,7 @@ describe('ActivityPubAPI', function () { | |
|
||
const actual = await api.search(handle); | ||
const expected = { | ||
profiles: [ | ||
accounts: [ | ||
{ | ||
handle, | ||
name: 'Foo Bar' | ||
|
@@ -880,7 +880,7 @@ describe('ActivityPubAPI', function () { | |
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('It returns an empty array when there are no profiles in the response', async function () { | ||
test('It returns an empty array when there are no accounts in the response', async function () { | ||
const handle = '@[email protected]'; | ||
|
||
const fakeFetch = Fetch({ | ||
|
@@ -905,7 +905,7 @@ describe('ActivityPubAPI', function () { | |
|
||
const actual = await api.search(handle); | ||
const expected = { | ||
profiles: [] | ||
accounts: [] | ||
}; | ||
|
||
expect(actual).toEqual(expected); | ||
|
Oops, something went wrong.