diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..760dacb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:16.19.1-alpine3.17 + +# For development add /bin/bash +RUN apk update && apk add --no-cache bash + +# Set up the server directory +WORKDIR /app +COPY . /app + +# Install yarn dependencies +RUN yarn install --network-timeout 100000 +RUN yarn build + +# Install yarn dependencies +RUN yarn global add pm2 +RUN yarn install +RUN yarn build + +# APP LOG DIRECTORY FROM pm2.config.js +RUN mkdir -p /home/zim/app-logs/the-data-explorer-api + +# Run `yarn docker` to build, migrate and run the server with pm2. +CMD ["yarn", "docker"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..91b5db0 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,15 @@ +FROM node:16.19.1-alpine3.17 + +# For development add /bin/bash +RUN apk update && apk add --no-cache bash + +# Set up the server directory +WORKDIR /app +COPY . /app + +# Install yarn dependencies +RUN yarn install --network-timeout 100000 +RUN yarn build + +# Run `yarn docker` to build, migrate and run the server with pm2. +CMD ["yarn", "dev"] diff --git a/package.json b/package.json index 982bbb3..2b56334 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "clean": "lb-clean dist *.tsbuildinfo .eslintcache", "rebuild": "yarn run clean && yarn run build", "dev": "nodemon server.js", - "deploy": "yarn prestart && pm2 start pm2.config.js --env production" + "deploy": "yarn prestart && pm2 start pm2.config.js --env production", + "docker": "yarn prestart && pm2-runtime start pm2.config.js --env production" }, "nodemonConfig": { "verbose": true,