-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.distroless.bun
50 lines (37 loc) · 1.33 KB
/
Dockerfile.distroless.bun
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Use a large Node.js base image to build the application and name it "build"
FROM oven/bun:slim as base
WORKDIR /src
# Build
FROM base as build
# Copy the necessary files for the dependency installation
COPY .npmrc /src
COPY package.json /src
COPY bun.lockb /src
# Install dependencies using bun
RUN bun install --frozen-lockfile
# Copy the rest of the application code, excluding .ssh and scripts
COPY . /src
# Copy .env.production and rename it to .env
COPY .env.production .env
# Build the application
RUN bun run build
# Runtime
# Instead of using a Node.js v22 image, we are using a distroless image. These are provided by google: https://github.com/GoogleContainerTools/distroless
FROM oven/bun:distroless as prod
WORKDIR /app
# Set environment variables
ENV NODE_ENV=production
ENV NUXT_PORT=80
ENV NITRO_PORT=80
ENV NITRO_HOST=0.0.0.0
ENV NUXT_HOST=0.0.0.0
# ENV HOST=0.0.0.0
# Expose the port
EXPOSE 80
# Copy the built application from the "build" image into the "prod" image
COPY --from=build /src/.output /app/.output
# Optional, only needed if you rely on unbundled dependencies
# COPY --from=build /app/node_modules /app/node_modules
# Start the Nuxt application
# Since this image only contains node.js, we do not need to specify the node command and simply pass the path to the index.mjs file!
CMD ["/app/.output/server/index.mjs"]