Update Dockerfile to include cache mounts + update healthcheck to new endpoint

pull/62/head
Alex 2 years ago
parent 516b812b2b
commit b023801fe4

@ -7,18 +7,18 @@ WORKDIR /app
COPY --link package.json pnpm-lock.yaml* ./
RUN <<EOF
set -xe
apk add --no-cache libc6-compat
apk add --no-cache --virtual .gyp python3 make g++
EOF
RUN <<EOF
RUN --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk \
<<EOF
set -xe
apk add libc6-compat
apk add --virtual .gyp python3 make g++
yarn global add pnpm
pnpm install
EOF
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm fetch | grep -v "cross-device link not permitted\|Falling back to copying packages from store"
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm install -r --offline
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
@ -45,9 +45,8 @@ ENV NODE_ENV production
WORKDIR /app
# Copy files from context
# Copy files from context (this allows the files to copy before the builder stage is done).
COPY --link package.json next.config.js ./
COPY --link --chmod=755 healthcheck.js ./
COPY --link /public ./public
# Copy files from builder
@ -55,9 +54,9 @@ COPY --link --from=builder /app/.next/standalone ./
COPY --link --from=builder /app/.next/static/ ./.next/static/
EXPOSE 3000
ENV PORT='3000'
ENV PORT 3000
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s \
CMD node ./healthcheck.js
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \
CMD wget --no-verbose --tries=1 --spider --no-check-certificate http://localhost:$PORT/api/healthcheck || exit 1
CMD ["node", "server.js"]
CMD ["node", "server.js"]

@ -1,22 +0,0 @@
var http = require("http");
const PORT = process.env.PORT || "3000";
var options = {
host: "localhost",
port: PORT,
timeout: 2000,
};
var request = http.request(options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
if (res.statusCode == 200) {
process.exit(0);
} else {
process.exit(1);
}
});
request.on("error", function (err) {
console.log("ERROR");
process.exit(1);
});
request.end();
Loading…
Cancel
Save