-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial service entrypoint and dockerfile
- Loading branch information
Showing
5 changed files
with
3,086 additions
and
0 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 @@ | ||
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,34 @@ | ||
FROM node:18-alpine as build | ||
|
||
# Move files into the image and install | ||
WORKDIR /app | ||
COPY ./service ./service | ||
|
||
WORKDIR /app/service | ||
RUN yarn install --production --frozen-lockfile > /dev/null | ||
|
||
# Uses assets from build stage to reduce build size | ||
FROM node:18-alpine | ||
|
||
# RUN npm install -g yarn | ||
RUN apk add --update dumb-init | ||
|
||
# Avoid zombie processes, handle signal forwarding | ||
ENTRYPOINT ["dumb-init", "--"] | ||
|
||
WORKDIR /app/service | ||
COPY --from=build /app /app | ||
RUN mkdir /app/data && chown node /app/data | ||
|
||
VOLUME /app/data | ||
EXPOSE 3000 | ||
ENV PDS_PORT=3000 | ||
ENV NODE_ENV=production | ||
|
||
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user | ||
USER node | ||
CMD ["node", "--heapsnapshot-signal=SIGUSR2", "--enable-source-maps", "index.js"] | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/bluesky-social/pds | ||
LABEL org.opencontainers.image.description="ATP Personal Data Server (PDS)" | ||
LABEL org.opencontainers.image.licenses=MIT |
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,33 @@ | ||
"use strict"; | ||
const { | ||
PDS, | ||
Database, | ||
envToCfg, | ||
envToSecrets, | ||
readEnv, | ||
} = require("@atproto/pds"); | ||
|
||
const main = async () => { | ||
const env = readEnv(); | ||
const cfg = envToCfg(env); | ||
const secrets = envToSecrets(env); | ||
const pds = await PDS.create(cfg, secrets); | ||
if (cfg.db.dialect === "pg") { | ||
// Migrate using credentialed user | ||
const migrateDb = Database.postgres({ | ||
url: cfg.db.migrationUrl, | ||
schema: cfg.db.schema, | ||
}); | ||
await migrateDb.migrateToLatestOrThrow(); | ||
await migrateDb.close(); | ||
} else { | ||
await pds.ctx.db.migrateToLatestOrThrow(); | ||
} | ||
await pds.start(); | ||
// Graceful shutdown (see also https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/) | ||
process.on("SIGTERM", async () => { | ||
await pds.destroy(); | ||
}); | ||
}; | ||
|
||
main(); |
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,11 @@ | ||
{ | ||
"name": "pds", | ||
"private": true, | ||
"version": "0.0.0", | ||
"description": "Service entrypoint for atproto personal data server", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@atproto/pds": "0.2.0-beta.0" | ||
} | ||
} |
Oops, something went wrong.