From 69efe3d53464ef243d3c52f857a31923f42d4f62 Mon Sep 17 00:00:00 2001 From: Th1b4ud Date: Sun, 14 Aug 2022 02:16:19 +0200 Subject: [PATCH] Add dockerfile and docker documentation in README.md --- .dockerignore | 2 ++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..93f1361 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..713fa70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# docker build . -t mokuappio/serverless-invoices +# docker run -p 80:8080 -d mokuappio/serverless-invoices + +FROM node:16 + +RUN npm install -g http-server + +# Create app directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install +RUN npm install + +# Bundle app source +COPY . . + +# Copy config (grrrr not written in README!! https://github.com/mokuappio/serverless-invoices/issues/9) +COPY src/config/app.config.example.js ./src/config/app.config.js + +# Build the app +RUN npm run build + +# Choose what port to expose +EXPOSE 8080 + +# Run the app +CMD ["http-server", "dist"] diff --git a/README.md b/README.md index c09dcf1..77b7cce 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,25 @@ npm run build npm run lint ``` +## Run with Docker + +It is necessary to install Docker before running the following commands. + +``` +git clone https://github.com/mokuappio/serverless-invoices.git +cd serverless-invoices.git +docker build . -t mokuappio/serverless-invoices +docker run -p 80:8080 -d --rm mokuappio/serverless-invoices +``` + +It is possible to add an alias in your .bashrc/.zshrc file to launch the app on the fly. + +``` +echo "alias serverless-invoices='docker run -p 80:8080 -d --rm mokuappio/serverless-invoices'" >> ~/.zshrc +source ~/.zshrc +serverless-invoices +``` + ## Topics - invoices management - invoicing solution