diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6d68aea --- /dev/null +++ b/.dockerignore @@ -0,0 +1,24 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile index 2f38d5f..1af0e96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,53 +1,66 @@ -########## Original Dockerfile ########## -FROM node:18 +# ########## Original Dockerfile ########## +# FROM node:18 -# Install basic development tools -RUN apt update && apt install -y less man-db sudo - -# Ensure default `node` user has access to `sudo` -ARG USERNAME=node -RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME - -# Set `DEVCONTAINER` environment variable to help with orientation -#ENV DEVCONTAINER=true -#! env declarations not copied to devcontainer - -########## Modified Dockerfile ########## - -FROM node:18-alpine - -## Install basic development tools -#RUN apt update && apt install -y less man-db sudo +# # Install basic development tools +# RUN apt update && apt install -y less man-db sudo # # Ensure default `node` user has access to `sudo` # ARG USERNAME=node # RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ # && chmod 0440 /etc/sudoers.d/$USERNAME +# # Set `DEVCONTAINER` environment variable to help with orientation +# #ENV DEVCONTAINER=true +# #! env declarations not copied to devcontainer + +# ########## Modified Dockerfile ########## + +# FROM node:18-alpine + +# ## Install basic development tools +# #RUN apt update && apt install -y less man-db sudo + +# # # Ensure default `node` user has access to `sudo` +# # ARG USERNAME=node +# # RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ +# # && chmod 0440 /etc/sudoers.d/$USERNAME + +# WORKDIR /app + +# # Copy package.json and package-lock.json +# COPY package*.json ./ + + +# #RUN apt-get update && apt-get install -y git +# #RUN git config --global user.name "Dobromir Popov" +# #RUN git config --global user.email "d-popov@abv.bg" + + +# # Install dependencies +# RUN npm install ws express request node-persist body-parser dotenv #--only=production + +# # Copy the rest of the application files +# COPY . . + +# # Start the application +# #CMD ["npm", "start"] +# CMD npm start +# # portainer: '-c' 'echo Container started; trap "exit 0" 15; exec npm start' + +# EXPOSE 8080 8081 + +# # Set `DEVCONTAINER` environment variable to help with orientation +# ENV DEVCONTAINER=true + + +# oriiginal +FROM node:lts-alpine +ENV NODE_ENV=production WORKDIR /app - -# Copy package.json and package-lock.json -COPY package*.json ./ - - -#RUN apt-get update && apt-get install -y git -#RUN git config --global user.name "Dobromir Popov" -#RUN git config --global user.email "d-popov@abv.bg" - - -# Install dependencies -RUN npm install ws express request node-persist body-parser dotenv #--only=production - -# Copy the rest of the application files +COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] +RUN npm install --production --silent && mv node_modules ../ COPY . . - -# Start the application -#CMD ["npm", "start"] -CMD npm start -# portainer: '-c' 'echo Container started; trap "exit 0" 15; exec npm start' - EXPOSE 8080 8081 - -# Set `DEVCONTAINER` environment variable to help with orientation -ENV DEVCONTAINER=true +RUN chown -R node /app +USER node +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml new file mode 100644 index 0000000..a3107c4 --- /dev/null +++ b/docker-compose.debug.yml @@ -0,0 +1,14 @@ +version: '3.4' + +services: + kevinai: + image: kevinai + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: development + ports: + - 3000:3000 + - 9229:9229 + command: ["node", "--inspect=0.0.0.0:9229", "web/server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0b3f72b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.4' + +services: + kevinai: + image: kevinai + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: production + ports: + - 3000:3000