From f674f1823e8824297ff92555160daf1fc038b3d0 Mon Sep 17 00:00:00 2001
From: Eugen Ciur <eugen@papermerge.com>
Date: Fri, 24 Dec 2021 08:42:03 +0100
Subject: [PATCH] dockerfile/docker image

---
 app/authenticators/auth-token.js |  7 ++++++-
 config/environment.js            |  2 +-
 docker/Dockerfile                | 20 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 docker/Dockerfile

diff --git a/app/authenticators/auth-token.js b/app/authenticators/auth-token.js
index 538eaaf..2c340a3 100644
--- a/app/authenticators/auth-token.js
+++ b/app/authenticators/auth-token.js
@@ -1,3 +1,4 @@
+import ENV from 'papermerge/config/environment';
 import Base from 'ember-simple-auth/authenticators/base';
 
 
@@ -26,7 +27,7 @@ export default class AuthToken extends Base {
   async authenticate(username, password) {
     let response, error;
 
-    response = await fetch('http://localhost:8000/api/auth-token/', {
+    response = await fetch(`${this.base_url}/auth-token/`, {
       method: 'POST',
       headers: {
         'Content-Type': 'application/json',
@@ -41,4 +42,8 @@ export default class AuthToken extends Base {
       throw new Error(error.non_field_errors[0]);
     }
   }
+
+  get base_url() {
+    return `${ENV.APP.HOST}/${ENV.APP.NAMESPACE}/`;
+  }
 }
diff --git a/config/environment.js b/config/environment.js
index f87a1e6..7f8d3fa 100644
--- a/config/environment.js
+++ b/config/environment.js
@@ -18,7 +18,7 @@ module.exports = function (environment) {
     },
 
     APP: {
-      NAMESPACE: 'api',
+      NAMESPACE: '',
       WS_NAMESPACE: 'ws'  // websockets namespace
       // Here you can pass flags/options to your application instance
       // when it is created
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..8d46ebc
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,20 @@
+FROM node:14 as build
+
+LABEL author="Eugen Ciur <eugen@papermerge.com>"
+
+WORKDIR /src
+ENV PATH /src/node_modules/.bin:$PATH
+
+COPY app ./app
+COPY config ./config
+COPY public ./public
+COPY .ember-cli ./
+COPY ember-cli-build.js ./
+COPY package.json ./
+
+RUN npm install
+RUN ember build --environment production
+
+FROM nginx:1.21.1-alpine
+
+COPY --from=build /src/dist/ /usr/share/nginx/html
-- 
GitLab