-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
61 lines (48 loc) · 1.63 KB
/
Dockerfile
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
52
53
54
55
56
57
58
59
60
61
FROM denoland/deno:alpine-2.1.5
# Set environment variables
ENV HOME=/app \
DENO_DIR=/app/.deno \
DENO_ENV=production \
NODE_DEBUG=* \
XDG_CONFIG_HOME=/app/.config \
XDG_CACHE_HOME=/app/.cache \
XDG_DATA_HOME=/app/.local/share \
NPM_CONFIG_CACHE=/app/.npm
# Install additional tools
RUN apk add --no-cache bash
# Create necessary directories
RUN mkdir -p /app \
/app/.deno \
/app/.npm \
/app/.config \
/app/.cache \
/app/.local/share \
/app/node_modules/.deno
# Set up permissions more securely
RUN chown -R deno:deno /app && \
chmod -R 755 /app && \
chmod -R 775 /app/.deno /app/.npm /app/node_modules/.deno
WORKDIR /app
# Copy files and set permissions
COPY --chown=deno:deno . .
# Clean any existing caches
RUN rm -rf node_modules/.deno && \
rm -rf .npm && \
rm -rf .deno
# Switch to deno user for build steps
USER deno
# Build steps with all permissions granted and error handling
RUN deno run --allow-all main.ts build --lock=lock.json --lock-write || (echo "Build failed" && exit 1)
# Cache dependencies with proper error handling
RUN DENO_DIR=/app/.deno \
NPM_CONFIG_CACHE=/app/.npm \
deno cache --reload --lock=lock.json main.ts || (echo "Cache failed" && exit 1)
# Verify the build environment
RUN echo "Verifying environment and permissions:" && \
ls -la /app && \
ls -la /app/.deno || true && \
ls -la /app/node_modules/.deno || true && \
ls -la /app/.npm || true
EXPOSE 8000
# Add all necessary permissions to the runtime command
CMD ["deno", "run", "--allow-net", "--allow-read", "--allow-run", "--allow-write", "--allow-env", "--allow-sys", "main.ts"]