Spaces:
Sleeping
Sleeping
bradduy
commited on
Commit
·
7ec743e
1
Parent(s):
66afcc2
update dokcer
Browse files- Dockerfile +18 -10
Dockerfile
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
-
# Use
|
2 |
FROM node:20
|
3 |
|
4 |
-
#
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Copy package.json and install dependencies
|
8 |
-
COPY package.json
|
9 |
-
RUN yarn install
|
10 |
|
11 |
-
#
|
|
|
|
|
|
|
12 |
RUN useradd -m appuser
|
13 |
|
14 |
-
#
|
15 |
RUN chown -R appuser /app
|
16 |
|
17 |
# Switch to the non-root user
|
@@ -20,8 +22,14 @@ USER appuser
|
|
20 |
# Copy the rest of the application code
|
21 |
COPY . .
|
22 |
|
23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
EXPOSE 3000
|
25 |
|
26 |
-
#
|
27 |
-
CMD ["yarn", "
|
|
|
1 |
+
# Use the official Node.js image as a base
|
2 |
FROM node:20
|
3 |
|
4 |
+
# Set the working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Copy package.json and yarn.lock to install dependencies
|
8 |
+
COPY package.json yarn.lock ./
|
|
|
9 |
|
10 |
+
# Install dependencies using Yarn (use --frozen-lockfile for consistency)
|
11 |
+
RUN yarn install --frozen-lockfile --unsafe-perm=true
|
12 |
+
|
13 |
+
# Create a non-root user and set permissions
|
14 |
RUN useradd -m appuser
|
15 |
|
16 |
+
# Ensure the /app directory is owned by the non-root user
|
17 |
RUN chown -R appuser /app
|
18 |
|
19 |
# Switch to the non-root user
|
|
|
22 |
# Copy the rest of the application code
|
23 |
COPY . .
|
24 |
|
25 |
+
# Create the .next directory (this can sometimes be needed to ensure build process has the right permissions)
|
26 |
+
RUN mkdir -p /app/.next && chown -R appuser /app/.next
|
27 |
+
|
28 |
+
# Build the Next.js app
|
29 |
+
RUN yarn build
|
30 |
+
|
31 |
+
# Expose the port the app will run on
|
32 |
EXPOSE 3000
|
33 |
|
34 |
+
# Start the Next.js app
|
35 |
+
CMD ["yarn", "start"]
|