From 88d47a4391f02f71831574f7b5fdd3ef352fc3c2 Mon Sep 17 00:00:00 2001 From: Pingumask Date: Mon, 27 Feb 2023 16:32:45 +0000 Subject: [PATCH] Dockerization of dev env --- .env.template | 3 +++ .gitignore | 2 ++ Dockerfile | 10 ++++++++++ docker-compose.template.yml | 17 +++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 .env.template create mode 100644 Dockerfile create mode 100644 docker-compose.template.yml diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..cd6a928 --- /dev/null +++ b/.env.template @@ -0,0 +1,3 @@ +NODE_PORT=8080 +SSH_KEYS=""# path to user/.ssh folder. Note : this folder needs to be owned by root in wsl. This requires having 2 separate ssh folders if you have other docker instances requiring a www-data owned ssh folder +PROJECT_LOCAL_PATH=D:/Projets/Townsquare diff --git a/.gitignore b/.gitignore index 75e0a77..939cc8a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ node_modules dist *.pem *.log +.env +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b55a9df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:16 +RUN apt update && apt install -y\ + git +WORKDIR /app +COPY package*.json . +RUN npm install +# npm rebuild avoids having misconfigurations if npm install has been run in the folder from windows before building the docker image +RUN npm rebuild +COPY . . +CMD ["npm","run","serve"] diff --git a/docker-compose.template.yml b/docker-compose.template.yml new file mode 100644 index 0000000..61bbfe8 --- /dev/null +++ b/docker-compose.template.yml @@ -0,0 +1,17 @@ +version: "3.5" +services: + blood_on_the_clocktower: + container_name: frontend + build: "${PROJECT_LOCAL_PATH}" + restart: unless-stopped + volumes: + - "${SSH_KEYS}:/root/.ssh" + environment: + NODE_ENV: development + ports: + - "${NODE_PORT}:8080" + working_dir: /app + logging: + driver: "json-file" + options: + max-size: "200k"