Fix TypeScript errors and update Dockerfile for Alpine compatibility
This commit is contained in:
21
Dockerfile
21
Dockerfile
@@ -8,7 +8,8 @@ RUN apk add --no-cache \
|
||||
make \
|
||||
python3 \
|
||||
curl \
|
||||
ca-certificates
|
||||
ca-certificates \
|
||||
vips-dev
|
||||
|
||||
# Configure npm for better reliability
|
||||
RUN npm config set strict-ssl false
|
||||
@@ -16,18 +17,24 @@ RUN npm config set registry https://registry.npmjs.org/
|
||||
RUN npm config set fetch-retry-mintimeout 20000
|
||||
RUN npm config set fetch-retry-maxtimeout 120000
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
# Install global packages needed for build
|
||||
RUN npm install -g typescript shx
|
||||
|
||||
# Clean npm cache and install dependencies
|
||||
# Copy package files and modify to prevent prepare script from running
|
||||
COPY package*.json ./
|
||||
RUN node -e "const pkg = require('./package.json'); delete pkg.scripts.prepare; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));"
|
||||
|
||||
# Install dependencies without running the prepare script, including sharp with the correct platform
|
||||
RUN npm cache clean --force && \
|
||||
npm install --legacy-peer-deps --no-optional
|
||||
npm install --legacy-peer-deps --no-optional && \
|
||||
npm install --platform=linuxmusl --arch=x64 sharp
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build TypeScript code
|
||||
RUN npm run build
|
||||
# Build TypeScript code manually
|
||||
RUN npx tsc && \
|
||||
npx shx chmod +x dist/*.js
|
||||
|
||||
# Switch to production for runtime
|
||||
ENV NODE_ENV=production
|
||||
|
||||
Reference in New Issue
Block a user