How to compile typescript in Dockerfile
08:51 28 Jun 2018

I'm having trouble compiling my nodejs typescript application from a Dockerfile. When I build my docker image an inspect it is missing the dist folder entirely.

Dockerfile:

# Template: Node.js dockerfile
# Description: Include this file in the root of the application to build a docker image.

# Enter which node build should be used. E.g.: node:argon 
FROM node:latest

# Create app directory for the docker image
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app/dist

# Install app dependencies from package.json. If modules are not included in the package.json file enter a RUN command. E.g. RUN npm install 
COPY package.json /usr/src/app/
RUN     npm install
RUN     npm install tsc -g
RUN     tsc

# Bundle app source
COPY . /usr/src/app

# Enter the command which should be used when the image starts up. E.g. CMD ["node", "app.js"]
CMD [ "node", "server.js"]

When I run the image locally and ls to reveal files/folders:

# ls
node_modules  package-lock.json  package.json  src

Any suggestions to where i am going wrong?

node.js typescript docker