Skip to content

[Bug]: docker, typescript issue #2597

@sebastienPoussard

Description

@sebastienPoussard

Link to the documentation page or resource

https://docs.strapi.io/cms/installation/docker#optional-docker-compose

Describe the bug

I want to create a docker-compose with STRAPI v5 and Postgres.
I follow the current documentation :

  • create the project sudo npx create-strapi@latest my-strapi
  • go into my /my-strapi folder, create the Dockerfile and build the image : sudo docker build --progress=plain --no-cache -t mystrapiapp:latest .
  • launch my docker-compose

Upon starting the STRAPI container give me this error :

error TS18003: No inputs were found in config file '/opt/app/tsconfig.json'. Specified 'include' paths were '["./","./**/*.ts","./**/*.js","src/**/*.json"]' and 'exclude' paths were '["node_modules/","build/","dist/",".cache/",".tmp/","src/admin/","**/*.test.*","src/plugins/**"]'.

my Docker-compose file :

version: "3"
services:
  strapi:
    container_name: strapi
    image: mystrapiapp:latest
    restart: unless-stopped
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: strapiDB
      DATABASE_PORT: ${DATABASE_PORT}
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      APP_KEYS: ${APP_KEYS}
      NODE_ENV: ${NODE_ENV}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.strapi.entrypoints=websecure"
      - "traefik.http.routers.strapi.rule=Host(`REDACTED`)"
      - "traefik.http.routers.strapi.tls=true"
      - "traefik.http.routers.strapi.tls.certresolver=myresolver"
      - "traefik.docker.network=traefik_strapi"
      # midleware for crowdsec bouncer
      - "traefik.http.middlewares.crowdsec-bouncer.forwardauth.address=http://traefik_crowdsec-bouncer:8080/api/v1/forwardAuth"
      - "traefik.http.routers.strapi.middlewares=crowdsec-bouncer@docker"
    volumes:
      - /data/strapi/strapi/config:/opt/app/config
      - /data/strapi/strapi/src:/opt/app/src
      - /data/strapi/my-strapi/package.json:/opt/package.json
      - /data/strapi/strapi/uploads:/opt/app/public/uploads
    #ports:
    #  - "1337:1337"
    networks:
      - traefik_strapi
    depends_on:
      - strapiDB

  strapiDB:
    container_name: strapiDB
    restart: unless-stopped
    image: postgres:16.0-alpine
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    volumes:
      - /data/strapi/postgresql:/var/lib/postgresql/data/ 
    #ports:
    #  - "5432:5432"
    networks:
      - traefik_strapi

volumes:
  strapi-data:

networks:
  traefik_strapi:
    external: true

my Dockerfile :

# Creating multi-stage build for production
FROM node:22-alpine AS build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /opt/
COPY package.json package-lock.json ./
RUN npm install -g node-gyp
RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production
ENV PATH=/opt/node_modules/.bin:$PATH
WORKDIR /opt/app
COPY . .
RUN npm run build

# Creating final production image
FROM node:22-alpine
RUN apk add --no-cache vips-dev
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY --from=build /opt/node_modules ./node_modules
WORKDIR /opt/app
COPY --from=build /opt/app ./
ENV PATH=/opt/node_modules/.bin:$PATH

RUN chown -R node:node /opt/app
USER node
EXPOSE 1337
CMD ["npm", "run", "start"]

my project structure :

.rw-r--r--  546 root root 21 Jul 08:34 .env
.rw-r--r--  205 root root 21 Jul 08:34 .env.example
.rw-r--r-- 1.4k root root 21 Jul 08:35 .gitignore
drwxr-xr-x    - root root 21 Jul 08:34 config
drwxr-xr-x    - root root 21 Jul 08:34 database
.rw-r--r--  861 root root 21 Jul 08:36 Dockerfile
.rw-r--r--  497 root root 21 Jul 08:34 favicon.png
drwxr-xr-x    - root root 21 Jul 08:35 node_modules
.rw-r--r-- 607k root root 21 Jul 08:35 package-lock.json
.rw-r--r-- 1.1k root root 21 Jul 08:34 package.json
drwxr-xr-x    - root root 21 Jul 08:34 public
.rw-r--r-- 2.2k root root 21 Jul 08:34 README.md
drwxr-xr-x    - root root 21 Jul 08:34 src
.rw-r--r--  942 root root 21 Jul 08:34 tsconfig
.rw-r--r--  738 root root 21 Jul 08:44 tsconfig.json
drwxr-xr-x    - root root 21 Jul 08:39 yarn.lock

content of tsconfig.json :

{
  "extends": "@strapi/typescript-utils/tsconfigs/server",
  "compilerOptions": {
    "outDir": "dist",
    "rootDir": ".",
    "sourceMap": true,
    "allowJs": true,
    "strict": false,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node",
    "module": "commonjs",
    "target": "es2019",
    "lib": ["es2019"],
    "types": ["node"]
  },
  "include": [
    "./",
    "src/**/*.ts",
    "src/**/*.js",
    "config/**/*.ts",
    "config/**/*.js",
    "database/**/*.ts",
    "database/**/*.js"
  ],
  "exclude": [
    "node_modules/",
    "build/",
    "dist/",
    ".cache/",
    ".tmp/",
    "src/admin/",
    "**/*.test.ts",
    "src/plugins/**"
  ]
}

Could someone help me debug this issue ?

Additional context

No response

Suggested improvements or fixes

No response

Related issue(s)/PR(s)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions