summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.docker/env1
-rw-r--r--.dockerignore5
-rw-r--r--.env.example6
-rw-r--r--api/Dockerfile30
-rw-r--r--docker-compose.yml44
5 files changed, 69 insertions, 17 deletions
diff --git a/.docker/env b/.docker/env
deleted file mode 100644
index 595b7ba2..00000000
--- a/.docker/env
+++ /dev/null
@@ -1 +0,0 @@
-MONGO_URL=mongodb://db:27017/fosscord?readPreference=secondaryPreferred
diff --git a/.dockerignore b/.dockerignore
index 61b7ef66..93d19905 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,2 +1,5 @@
 node_modules/
-db/
\ No newline at end of file
+db/
+dist/
+coverage/
+*.db
\ No newline at end of file
diff --git a/.env.example b/.env.example
new file mode 100644
index 00000000..72449f88
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,6 @@
+PRODUCTION=false
+
+DATABASE="postgres://fosscord:fosscord@db:5432/fosscord"
+
+STORAGE_PROVIDER=file
+STORAGE_LOCATION=/data
diff --git a/api/Dockerfile b/api/Dockerfile
index 08d15f72..78256be6 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -1,12 +1,28 @@
 FROM node:lts-alpine
+
 # needed for native packages (bcrypt, canvas)
-RUN apk add --no-cache make gcc g++ python cairo-dev jpeg-dev pango-dev giflib-dev
-WORKDIR /usr/src/fosscord-server
-COPY package.json .
-COPY package-lock.json .
-RUN npm rebuild bcrypt --build-from-source && npm install canvas --build-from-source
+RUN apk add --no-cache \
+    make \
+    gcc \
+    g++ \
+    python \
+    cairo-dev \
+    jpeg-dev \
+    pango-dev \
+    giflib-dev
+
+WORKDIR /usr/src/fosscord-api
+
+RUN npm rebuild bcrypt --build-from-source \
+    && npm install canvas --build-from-source
+
+COPY api/package.json api/package-lock.json ./
+COPY util ../util
 RUN npm install
-COPY . .
+
+COPY api/ .
+
+RUN npm run build
+
 EXPOSE 3001
-RUN npm run build-docker
 CMD ["node", "dist/start.js"]
diff --git a/docker-compose.yml b/docker-compose.yml
index 5861e12f..3dca75fb 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,24 +1,52 @@
+---
 version: "3"
+
 services:
     db:
         hostname: fosscord_db
-        image: mongo:latest
+        image: postgres:latest
         volumes:
-            - ./db:/data/db
+            - db_data:/var/lib/postgres
         restart: unless-stopped
+        ports:
+            - 5432:5432
+        environment:
+            POSTGRES_USER: fosscord
+            POSTGRES_DATABASE: fosscord
+            POSTGRES_PASSWORD: fosscord
+
     api:
-        hostname: fosscord_api
-        image: fosscord/api
+        build:
+            context: .
+            dockerfile: api/Dockerfile
         depends_on:
             - db
         ports:
             - 3001:3001
-        env_file: ./.docker/env
+        env_file: .env
+
     gateway:
-        hostname: fosscord_gateway
-        image: fosscord/gateway
+        build:
+            context: .
+            dockerfile: gateway/Dockerfile
         depends_on:
             - db
         ports:
             - 3002:3002
-        env_file: ./.docker/env
\ No newline at end of file
+        env_file: .env
+
+    cdn:
+        build:
+            context: .
+            dockerfile: cdn/Dockerfile
+        depends_on:
+            - db
+        ports:
+            - 3003:3003
+        volumes:
+            - cdn_data:/data
+        env_file: .env
+
+volumes:
+    db_data: {}
+    cdn_data: {}