-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.test
More file actions
48 lines (37 loc) · 1.4 KB
/
Dockerfile.test
File metadata and controls
48 lines (37 loc) · 1.4 KB
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
FROM node:25-slim
# Install git for cloning function repositories, Redis server, and Redis client tools
RUN apt-get update && apt-get install -y \
git \
curl \
redis-server \
redis-tools \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy package files and prepare script (needed for npm lifecycle hooks)
COPY package*.json ./
COPY scripts/prepare.js ./scripts/
# Install ALL dependencies (including devDependencies for Jest/Nock)
RUN npm ci
# Copy application code
COPY . .
# Create functions directory
RUN mkdir -p functions logs
# Configure Redis to bind to localhost only and use /app for data
RUN mkdir -p /app/redis && \
echo "bind 127.0.0.1" > /etc/redis/redis.conf && \
echo "dir /app/redis" >> /etc/redis/redis.conf && \
echo "logfile /app/redis/redis.log" >> /etc/redis/redis.conf && \
echo "pidfile /app/redis/redis.pid" >> /etc/redis/redis.conf
# Create non-root user for security
RUN groupadd -r serverless && useradd -r -g serverless serverless
RUN chown -R serverless:serverless /app
USER serverless
# Expose port (for completeness, but not needed for test)
EXPOSE 3000
# Set environment variables
ENV NODE_ENV=test
ENV LOG_LEVEL=info
ENV HUSKY=0
# Start Redis in the background and open a shell for test commands
CMD ["sh", "-c", "redis-server --daemonize yes --port 6379 --bind 127.0.0.1 --requirepass ${REDIS_PASSWORD:-funcdock_internal} && bash"]