I trying to setup kubernetes on my local environment using docker. I've built the necessary docker image with this Dockerfile:
FROM node:9.11.1
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app/
EXPOSE 3002
CMD [ "npm", "start" ]
I then pushed this image to my private docker repo on the google cloud repository. Now i can confirm that i can push and pull the image from the cloud repo, so i then built a docker-compose using that repo as the image source file:
version: '3'
services:
redis:
image: redis
ports:
- 6379:6379
networks:
- my-network
mongodb:
image: mongo
ports:
- 27017:27017
volumes:
- ./db:/data/db
networks:
- my-network
my-test-app:
tty: true
image: gcr.io/my-test-app
ports:
- 3002:3002
depends_on:
- redis
- mongodb
networks:
- my-network
volumes:
- .:/usr/src/app
environment:
- REDIS_PORT=6379
- REDIS_HOST=redis
- DB_URI=mongodb://mongodb:27017/
command: bash -c "ls && npm install"
networks:
my-network:
driver: bridge
volumes:
mongodb:
Then finally building off of that i use Kubernetes kompose to generate my deployment file which looks like this:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.12.0 ()
creationTimestamp: null
labels:
io.kompose.service: my-test-app
name: my-test-app
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: my-test-app
spec:
imagePullSecrets:
- gcr-json-key
containers:
- args:
- bash
- -c
- ls && npm install
env:
- name: DB_URI
value: mongodb://mongodb:27017/
- name: REDIS_HOST
value: redis
- name: REDIS_PORT
value: "6379"
image: gcr.io/my-test-app
name: my-test-app
ports:
- containerPort: 3002
resources: {}
tty: true
volumeMounts:
- mountPath: /usr/src/app
name: my-test-app-claim0
restartPolicy: Always
volumes:
- name: my-test-app-claim0
persistentVolumeClaim:
claimName: my-test-app-claim0
status: {}
As you can see in the args section of my yaml i am listing all the files in my directory /usr/src/app
However it logs do the only file that appears is a single package-lock.json
file which causes the following install command to fail. This error however does not occur when i use docker-compose to launch my app so for some reason only my kubernetes is having trouble. Also i can confirm that my image does contain a package.json
file by running an interactive shell. I'm unsure on how to proceed so any help would be appreciated!