Fix dockerfile

This commit is contained in:
Jeremie Pardou-Piquemal 2022-12-29 21:47:41 +01:00 committed by Jérémie Pardou-Piquemal
parent 27c0214c5e
commit d2846e1605
7 changed files with 29 additions and 28 deletions

View File

@ -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

View File

@ -50,8 +50,5 @@
"required": false
}
},
"image": "heroku/nodejs",
"addons": [
"heroku-redis"
]
"image": "heroku/nodejs"
}

View File

@ -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(
<React.StrictMode>
<Main />

View File

@ -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
}
}

View File

@ -18,4 +18,7 @@ export default defineConfig({
resolve: {
alias: [{ find: '@', replacement: resolve(projectRootDir, 'src') }],
},
build:{
chunkSizeWarningLimit: 1000
}
});

View File

@ -1,9 +1,5 @@
version: '3.0'
services:
redis:
image: redis:6.0.6
networks:
- db
darkwire.io:
build:
context: .

View File

@ -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)