Adonis & Docker & Kubernetes

Hi!

I’m trying to run the Adonis.js API in Kubernetes - unfortunately without success.
For my app, I used yarn and slim mode.

In .env file i set:

HOST=0.0.0.0
PORT=7000

My current Dockerfile:

FROM node:lts-alpine

WORKDIR . /app

COPY package.json ./
COPY yarn.lock ./

RUN yarn install
RUN yarn global add @adonisjs/cli nodemon

COPY . .

EXPOSE 7000

CMD [ "adonis", "serve" ]

I also tried other versions of node images, npm, ports and run commands.
When I start it locally I get:

SERVER STARTED 

info: serving app on http://0.0.0.0:7000

But I can’t connect to my API. Kubernetes is also not able to run this image. But I’m sure Kubernetes works fine because I have other node-based pods. I’m a bit new in Docker and Kubernetes and I have no idea what is wrong…

1 Like

Are you in the right folder within the pod? I use AWS Codepipeline with ECR containers for building my image but my docker looks like

FROM 173625198401.dkr.ecr.eu-west-1.amazonaws.com/adonisjs-4.1

COPY . ./www

ENV APP_ENV=production

WORKDIR /www

# Run it in port 3333
EXPOSE 3333

# Start it
CMD [ "adonis", "serve" ]

Hi lukas, did you get the solution for this problem ? I am facing the same problem and I dont know how to solve until now.
Tks

I had a stupid mistake – I don’t have my .env file in the repository on GitLab. Of course remember that you should’t put any password etc. to files in git repository. I use GitLab CI/CD variables to put that data during image building.

1 Like