mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-04 06:23:40 +01:00
Update Dockerfile to include cache mounts + update healthcheck to new endpoint
This commit is contained in:
parent
516b812b2b
commit
b023801fe4
25
Dockerfile
25
Dockerfile
@ -7,17 +7,17 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY --link package.json pnpm-lock.yaml* ./
|
COPY --link package.json pnpm-lock.yaml* ./
|
||||||
|
|
||||||
RUN <<EOF
|
RUN --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk \
|
||||||
|
<<EOF
|
||||||
set -xe
|
set -xe
|
||||||
apk add --no-cache libc6-compat
|
apk add libc6-compat
|
||||||
apk add --no-cache --virtual .gyp python3 make g++
|
apk add --virtual .gyp python3 make g++
|
||||||
|
yarn global add pnpm
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
RUN <<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"
|
||||||
set -xe
|
|
||||||
yarn global add pnpm
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm install -r --offline
|
||||||
pnpm install
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM node:16-alpine AS builder
|
FROM node:16-alpine AS builder
|
||||||
@ -45,9 +45,8 @@ ENV NODE_ENV production
|
|||||||
|
|
||||||
WORKDIR /app
|
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 package.json next.config.js ./
|
||||||
COPY --link --chmod=755 healthcheck.js ./
|
|
||||||
COPY --link /public ./public
|
COPY --link /public ./public
|
||||||
|
|
||||||
# Copy files from builder
|
# Copy files from builder
|
||||||
@ -55,9 +54,9 @@ COPY --link --from=builder /app/.next/standalone ./
|
|||||||
COPY --link --from=builder /app/.next/static/ ./.next/static/
|
COPY --link --from=builder /app/.next/static/ ./.next/static/
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV PORT='3000'
|
ENV PORT 3000
|
||||||
|
|
||||||
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s \
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \
|
||||||
CMD node ./healthcheck.js
|
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…
x
Reference in New Issue
Block a user