-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.alpine
51 lines (37 loc) · 1.37 KB
/
Dockerfile.alpine
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
51
# Set the Node.js version to be used; default is 20
ARG NODE_VERSION=20
# Start the build stage using the specified Node.js version on Alpine Linux
FROM node:${NODE_VERSION}-alpine as build-stage
# Set the working directory inside the container
WORKDIR /app
# Enable Corepack to manage package managers (like pnpm)
RUN corepack enable
# Copy the necessary files for the dependency installation
COPY .npmrc package.json pnpm-lock.yaml ./
# Install dependencies using pnpm, utilizing a cache for faster builds
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
pnpm install --frozen-lockfile
# Copy the rest of the application code into the container
COPY . .
# Copy .env.production and rename it to .env
COPY .env.production .env
# Build the Nuxt.js application
RUN pnpm build
# Start the production stage using the same Node.js version
FROM node:${NODE_VERSION}-alpine as production-stage
# Set the working directory inside the production container
WORKDIR /app
# Copy the built output from the build stage
COPY --from=build-stage /app/.output ./.output
# Using port 80 to allow access to the application
# 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 this port
EXPOSE 80
# Define the command to run the application
CMD ["node", ".output/server/index.mjs"]