Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +34 -2
Dockerfile
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
|
|
| 1 |
FROM node:22-alpine
|
|
|
|
|
|
|
| 2 |
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
COPY package*.json ./
|
|
|
|
|
|
|
| 4 |
RUN npm install
|
|
|
|
|
|
|
| 5 |
COPY . .
|
|
|
|
|
|
|
| 6 |
EXPOSE 7860
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
RUN chown -R node:node /app
|
|
|
|
|
|
|
| 9 |
USER node
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Node.js runtime as a parent image
|
| 2 |
FROM node:22-alpine
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# --- Build-time Arguments ---
|
| 8 |
+
# Declare arguments that we will pass during the build command.
|
| 9 |
+
# This makes the API key and other secrets available during the build process.
|
| 10 |
+
ARG GEMINI_API_KEY
|
| 11 |
+
ARG EMAIL_USER
|
| 12 |
+
ARG EMAIL_PASS
|
| 13 |
+
|
| 14 |
+
# Copy package.json and package-lock.json
|
| 15 |
COPY package*.json ./
|
| 16 |
+
|
| 17 |
+
# Install app dependencies
|
| 18 |
RUN npm install
|
| 19 |
+
|
| 20 |
+
# Copy the rest of the application's source code
|
| 21 |
COPY . .
|
| 22 |
+
|
| 23 |
+
# Expose the port the app runs on
|
| 24 |
EXPOSE 7860
|
| 25 |
+
|
| 26 |
+
# --- Build Step ---
|
| 27 |
+
# Set environment variables from the build arguments we declared earlier.
|
| 28 |
+
# The `npm run build` command will now be able to access these keys.
|
| 29 |
+
RUN env GEMINI_API_KEY=$GEMINI_API_KEY EMAIL_USER=$EMAIL_USER EMAIL_PASS=$EMAIL_PASS npm run build
|
| 30 |
+
|
| 31 |
+
# Change ownership of the app directory to the 'node' user for better security
|
| 32 |
RUN chown -R node:node /app
|
| 33 |
+
|
| 34 |
+
# Switch to the non-root 'node' user
|
| 35 |
USER node
|
| 36 |
+
|
| 37 |
+
# --- Runtime Command ---
|
| 38 |
+
# Define the command to run your app.
|
| 39 |
+
# The secrets will ALSO need to be available here if your app uses them at runtime.
|
| 40 |
+
# Hugging Face injects the runtime secrets automatically.
|
| 41 |
+
CMD ["npm", "run", "start"]
|
| 42 |
+
|