Skip to content

Commit

Permalink
fix build, replace yarn with npm
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Feb 20, 2024
1 parent 918f6ea commit 93a0d71
Show file tree
Hide file tree
Showing 4 changed files with 3,236 additions and 3,177 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM node:18-alpine as build
FROM node:20.11-alpine3.18 as build

RUN npm install -g pnpm

# Move files into the image and install
WORKDIR /app
COPY ./service ./
RUN yarn install --production --frozen-lockfile > /dev/null
RUN pnpm install --production --frozen-lockfile > /dev/null

# Uses assets from build stage to reduce build size
FROM node:18-alpine
FROM node:20.11-alpine3.18

RUN apk add --update dumb-init

Expand All @@ -19,6 +21,8 @@ COPY --from=build /app /app
EXPOSE 3000
ENV PDS_PORT=3000
ENV NODE_ENV=production
# potential perf issues w/ io_uring on this version of node
ENV UV_USE_IO_URING=0

CMD ["node", "--enable-source-maps", "index.js"]

Expand Down
16 changes: 10 additions & 6 deletions service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const main = async () => {
const secrets = envToSecrets(env);
const pds = await PDS.create(cfg, secrets);
await pds.start();
pds.app.get("/check-handle", checkHandleRoute);
httpLogger.info("pds has started");
pds.app.get("/check-handle", (req, res) => {
checkHandleRoute(pds, req, res);
});
// Graceful shutdown (see also https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/)
process.on("SIGTERM", async () => {
httpLogger.info("pds is stopping");
Expand All @@ -25,9 +28,9 @@ const main = async () => {
};

async function checkHandleRoute(
/** @type {PDS} */ pds,
/** @type {import('express').Request} */ req,
/** @type {import('express').Response} */ res,
/** @type {import('express').NextFunction} */ next
/** @type {import('express').Response} */ res
) {
try {
const { domain } = req.query;
Expand All @@ -37,8 +40,8 @@ async function checkHandleRoute(
message: "bad or missing domain query param",
});
}
const isHostedHandle = pds.ctx.cfg.availableUserDomains.find((avail) =>
domain.endsWith(avail)
const isHostedHandle = pds.ctx.cfg.identity.serviceHandleDomains.find(
(avail) => domain.endsWith(avail)
);
if (!isHostedHandle) {
return res.status(400).json({
Expand All @@ -54,7 +57,8 @@ async function checkHandleRoute(
});
}
return res.json({ did: account.did, handle: account.handle });
} catch {
} catch (err) {
httpLogger.error({ err }, "check handle failed");
return res.status(500).json({
error: "InternalServerError",
message: "Internal Server Error",
Expand Down
Loading

0 comments on commit 93a0d71

Please sign in to comment.