From 1cab0eca7268f49de3125432f8bb5c0d1c076ae4 Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sat, 8 May 2021 16:53:15 -0500 Subject: [PATCH 1/7] Setup: Add Dockerfile --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3fc2ab49 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:lts +RUN mkdir -p /usr/src/fosscord-gateway +WORKDIR /usr/src/fosscord-gateway +COPY package.json /usr/src/fosscord-gateway +RUN npm install +COPY . /usr/src/fosscord-gateway +EXPOSE 3002 +CMD ["npm", "start"] \ No newline at end of file From 81f6539165dea3958cfd2aef6b676cc7c246d200 Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sat, 8 May 2021 17:39:03 -0500 Subject: [PATCH 2/7] Docker: Basic dockerization of the gateway --- .docker/mongodb/mongod.conf | 2 ++ .gitignore | 4 +++- docker-compose.yml | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .docker/mongodb/mongod.conf create mode 100644 docker-compose.yml diff --git a/.docker/mongodb/mongod.conf b/.docker/mongodb/mongod.conf new file mode 100644 index 00000000..cbe0a2a5 --- /dev/null +++ b/.docker/mongodb/mongod.conf @@ -0,0 +1,2 @@ +replication: + replSetName: "rs0" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5c7cd31d..daf8591a 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,6 @@ dist # TernJS port file .tern-port -.DS_Store \ No newline at end of file +.DS_Store + +data \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9e665b1d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3" +services: + fosscord-gateway: + container_name: fosscord-gateway + restart: always + build: . + ports: + - "3002:3002" + links: + - mongo + env_file: .env + mongo: + container_name: mongo + image: mongo + volumes: + - ./data:/data/db + - ./.docker/mongodb/mongod.conf:/etc/mongod.conf + ports: + - "27017:27017" + command: ["-f", "/etc/mongod.conf"] From ac594ba31d087b0b1a00b42e758ed762ebfda1ee Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sat, 8 May 2021 17:48:19 -0500 Subject: [PATCH 3/7] Setup: Add env file and delete docker-compose.yml --- .env | 1 + .gitignore | 1 - docker-compose.yml | 20 -------------------- 3 files changed, 1 insertion(+), 21 deletions(-) create mode 100644 .env delete mode 100644 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 00000000..df6d28c8 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +MONGO_URL=mongodb://mongo:27017/fosscord?readPreference=secondaryPreferred \ No newline at end of file diff --git a/.gitignore b/.gitignore index daf8591a..d7a5d6dc 100644 --- a/.gitignore +++ b/.gitignore @@ -69,7 +69,6 @@ typings/ .yarn-integrity # dotenv environment variables file -.env .env.test # parcel-bundler cache (https://parceljs.org/) diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 9e665b1d..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: "3" -services: - fosscord-gateway: - container_name: fosscord-gateway - restart: always - build: . - ports: - - "3002:3002" - links: - - mongo - env_file: .env - mongo: - container_name: mongo - image: mongo - volumes: - - ./data:/data/db - - ./.docker/mongodb/mongod.conf:/etc/mongod.conf - ports: - - "27017:27017" - command: ["-f", "/etc/mongod.conf"] From f21b39d32e2e56916051a6fe358b31df36275ca0 Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sat, 8 May 2021 17:51:02 -0500 Subject: [PATCH 4/7] Docker: Switch to node:lts-alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3fc2ab49..c9f27b5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts +FROM node:lts-alpine RUN mkdir -p /usr/src/fosscord-gateway WORKDIR /usr/src/fosscord-gateway COPY package.json /usr/src/fosscord-gateway From 6f827ee9cdd3ba136a599630951bf00b3aa9a58f Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sat, 8 May 2021 17:57:18 -0500 Subject: [PATCH 5/7] Docker: Remove .docker as it is not needed in this repository --- .docker/mongodb/mongod.conf | 2 -- .env | 1 - .gitignore | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 .docker/mongodb/mongod.conf delete mode 100644 .env diff --git a/.docker/mongodb/mongod.conf b/.docker/mongodb/mongod.conf deleted file mode 100644 index cbe0a2a5..00000000 --- a/.docker/mongodb/mongod.conf +++ /dev/null @@ -1,2 +0,0 @@ -replication: - replSetName: "rs0" \ No newline at end of file diff --git a/.env b/.env deleted file mode 100644 index df6d28c8..00000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -MONGO_URL=mongodb://mongo:27017/fosscord?readPreference=secondaryPreferred \ No newline at end of file diff --git a/.gitignore b/.gitignore index d7a5d6dc..daf8591a 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ typings/ .yarn-integrity # dotenv environment variables file +.env .env.test # parcel-bundler cache (https://parceljs.org/) From a78102b6cf09b8e58c83faa19877fa9574f65d4c Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sun, 9 May 2021 10:18:11 -0500 Subject: [PATCH 6/7] Docker: Fix an issue were native dependencies werent able to build --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index c9f27b5e..00dae566 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,12 @@ FROM node:lts-alpine RUN mkdir -p /usr/src/fosscord-gateway WORKDIR /usr/src/fosscord-gateway COPY package.json /usr/src/fosscord-gateway +RUN apk add --no-cache --virtual build-dependencies add \ + python \ + make \ + g++ RUN npm install +RUN apk del build-dependencies COPY . /usr/src/fosscord-gateway EXPOSE 3002 CMD ["npm", "start"] \ No newline at end of file From f295c59a455ddde4aafd452908e0bafdf86ec59a Mon Sep 17 00:00:00 2001 From: Diego Magdaleno Date: Sun, 9 May 2021 10:25:27 -0500 Subject: [PATCH 7/7] Docker: fix the syntax of the apk command --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 00dae566..9adfcfe7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:lts-alpine RUN mkdir -p /usr/src/fosscord-gateway WORKDIR /usr/src/fosscord-gateway COPY package.json /usr/src/fosscord-gateway -RUN apk add --no-cache --virtual build-dependencies add \ +RUN apk --no-cache --virtual build-dependencies add \ python \ make \ g++