diff --git a/Dockerfile b/Dockerfile index 1e9cebc..1d08804 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ -FROM node:18-alpine3.17 - -# Installing yarn -RUN apt update -y && \ - apt install yarn=v1.22.4 -v -y +FROM node:18-bullseye-slim USER node:node +WORKDIR /home/node + # Server environmental variables will be put into server/.env ENV MAILGUN_API_KEY=api-key \ MAILGUN_DOMAIN=darkwire.io \ @@ -22,11 +20,11 @@ ENV TZ=UTC \ VITE_API_PROTOCOL=http \ VITE_API_PORT=3001 \ VITE_COMMIT_SHA=some_sha \ - VITE_MAX_FILE_SIZE=4 + VITE_MAX_FILE_SIZE=4 COPY --chown=node:node . . -RUN yarn build +RUN yarn && yarn build STOPSIGNAL SIGINT EXPOSE 3001 diff --git a/app.json b/app.json index 971527b..042fb5b 100644 --- a/app.json +++ b/app.json @@ -50,8 +50,5 @@ "required": false } }, - "image": "heroku/nodejs", - "addons": [ - "heroku-redis" - ] + "image": "heroku/nodejs" } \ No newline at end of file diff --git a/client/src/main.tsx b/client/src/main.tsx index 7d288be..6dfd446 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -12,6 +12,7 @@ import 'bootstrap/dist/js/bootstrap.bundle.min.js'; import configureStore from '@/store/'; import Home from '@/components/Home/'; import { hasTouchSupport } from '@/utils/dom'; +import { AlertTriangle } from 'react-feather'; const store = configureStore(); @@ -45,6 +46,11 @@ const Main = () => { const root = createRoot(document.getElementById('root') as HTMLElement); +if (!window.crypto || !window.crypto.subtle) { + window.alert("You must access Darkwire from a secure HTTPS connection.") + throw new Error("You must access Darkwire from a secure HTTPS connection.") +} + root.render(
diff --git a/client/src/utils/crypto.js b/client/src/utils/crypto.js index dd9f812..5bb9fa5 100644 --- a/client/src/utils/crypto.js +++ b/client/src/utils/crypto.js @@ -3,7 +3,7 @@ export default class Crypto { this._crypto = window.crypto || false; if (!this._crypto || (!this._crypto.subtle && !this._crypto.webkitSubtle)) { - return false; + return false } } diff --git a/client/vite.config.ts b/client/vite.config.ts index db6aff4..460b8c2 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -18,4 +18,7 @@ export default defineConfig({ resolve: { alias: [{ find: '@', replacement: resolve(projectRootDir, 'src') }], }, + build:{ + chunkSizeWarningLimit: 1000 + } }); diff --git a/docker-compose.yaml b/docker-compose.yaml index b692286..90f2f58 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,9 +1,5 @@ version: '3.0' services: - redis: - image: redis:6.0.6 - networks: - - db darkwire.io: build: context: . diff --git a/readme.md b/readme.md index b719190..29d1a1c 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ Simple encrypted web chat. Powered by [socket.io](http://socket.io), the [web cr ### Darkwire Server -[Darkwire server](/server) is a Node.js application that requires redis. +[Darkwire server](/server) is a Node.js application. ### Darkwire Web Client @@ -21,19 +21,20 @@ The Darkwire.io [web client](/client) is written in JavaScript with React JS and Copy `.env.dist` files in `server/` and `client/` directories without the `.dist` extensions and adapt them to your needs. -You need [Redis](https://redis.io/) in order to make the server works. -A simple way to achieve this, if you have docker, is to execute the following -command: +You must have a https connection for Darkwire to work because it's using crypto browser +API which is accessible only on localhost and behind a https connection. + + +#### Manual setup + +You can use nvm to install the right version of node using this command: ``` -docker run --name darkwire-redis --rm -p 6379:6379 -d redis redis-server --appendonly yes +nvm install # If not already installed +nvm use +npm install yarn -g ``` -Alternatively, you can select the _memory_ `STORE_BACKEND` instead of _redis_ -in your server `.env` file to avoid Redis use. - -#### Setup - Install dependencies ``` @@ -55,7 +56,7 @@ Just run the following: $ docker-compose up ``` -This will automatically create the default `.env` files, and run redis for you. +This will automatically create the default `.env` files for you. ### Production @@ -82,7 +83,7 @@ $ docker build --tag darkwire.io:latest . Then run it. Example: ``` -$ docker run --name darkwire.io --env STORE_HOST=redis://redis.host:6379 darkwire.io +$ docker run --init --name darkwire.io --rm -p 3001:3001 darkwire.io ``` You are able to use any of the enviroment variables available in `server/.env.dist` and `client/.env.dist`. The defaults are available in [Dockerfile](Dockerfile)