strapi-community / strapi-tool-dockerize

Easy add support for docker to your strapi project
MIT License
543 stars 35 forks source link

TS container does not start and errors are about JS files. #74

Closed askpatrickw closed 1 year ago

askpatrickw commented 1 year ago

🐛 Bug Report

🤷‍♀️ What did you do

npx @strapi-community/dockerize
 Do you want to create a new Strapi Project … No / Yes
✔ Whats the name of the project? … dock
✔ Do you want to use TypeScript … No / Yes
✔ Do you want to assign a path for new project ? (leave blank for current directory ) … /Users/patrickwalters/code/exit83/strapi-test
(...)
 Do you want to create a docker-compose file? 🐳 … No / Yes
✔ What environment do you want to configure for? › Development
🐳  Dockerfile for DEVELOPMENT added

docker build ./
docker run <image_id>

⛔️ Error log

Starting the compilation for TypeScript files in /opt/app
Error: Middleware "strapi::session": App keys are required. Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])
    at instantiateMiddleware (/opt/node_modules/@strapi/strapi/lib/services/server/middleware.js:13:11)
    at resolveMiddlewares (/opt/node_modules/@strapi/strapi/lib/services/server/middleware.js:57:18)
    at registerApplicationMiddlewares (/opt/node_modules/@strapi/strapi/lib/services/server/register-middlewares.js:66:29)
    at async Object.initMiddlewares (/opt/node_modules/@strapi/strapi/lib/services/server/index.js:102:7)
    at async Strapi.bootstrap (/opt/node_modules/@strapi/strapi/lib/Strapi.js:477:5)
    at async Strapi.load (/opt/node_modules/@strapi/strapi/lib/Strapi.js:491:5)
    at async workerProcess (/opt/node_modules/@strapi/strapi/lib/commands/actions/develop/action.js:110:26)

🙇‍♀️ Expected behavior/code

I expected the container to start.

I definitely did not expect to see an error reference in a .JS file in a .TS project.

ls config
admin.ts       api.ts         database.ts    middlewares.ts server.ts
cat Dockerfile

FROM node:16-alpine
# Installing libvips-dev for sharp Compatability
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY ./package.json ./package-lock.json ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN npm install
WORKDIR /opt/app
COPY ./ .
RUN npm run build
EXPOSE 1337
CMD ["npm", "run", "develop"]
Eventyret commented 1 year ago

@SudeepPatel-0812 want to have a look?

SudeepPatel-0812 commented 1 year ago

Hi @Eventyret yes sure I'll work on it. Thanks!

Eventyret commented 1 year ago

Replicated, will try test this a bit more. When you use docker run xxx then you also need to pass in .env variables into it as .env is not copied into the docker image

There is more info here. https://docs.docker.com/engine/reference/commandline/run/#env

So will close this