File size: 1,224 Bytes
b1e7cf3
26f4db3
b1e7cf3
 
26f4db3
b1e7cf3
 
 
 
 
 
 
 
 
26f4db3
b1e7cf3
 
26f4db3
b1e7cf3
 
26f4db3
b1e7cf3
 
26f4db3
b1e7cf3
 
 
 
 
 
 
26f4db3
b1e7cf3
 
26f4db3
b1e7cf3
 
 
 
 
c83e55f
b1e7cf3
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
# Use an official Node.js runtime as a parent image
FROM node:22-alpine

# Set the working directory in the container
WORKDIR /app

# --- Build-time Arguments ---
# Declare arguments that we will pass during the build command.
# This makes the API key and other secrets available during the build process.
ARG GEMINI_API_KEY
ARG EMAIL_USER
ARG EMAIL_PASS

# Copy package.json and package-lock.json
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the rest of the application's source code
COPY . .

# Expose the port the app runs on
EXPOSE 7860

# --- Build Step ---
# Set environment variables from the build arguments we declared earlier.
# The `npm run build` command will now be able to access these keys.
RUN env GEMINI_API_KEY=$GEMINI_API_KEY EMAIL_USER=$EMAIL_USER EMAIL_PASS=$EMAIL_PASS npm run build

# Change ownership of the app directory to the 'node' user for better security
RUN chown -R node:node /app

# Switch to the non-root 'node' user
USER node

# --- Runtime Command ---
# Define the command to run your app.
# The secrets will ALSO need to be available here if your app uses them at runtime.
# Hugging Face injects the runtime secrets automatically.
CMD ["npm", "run", "dev"]