mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-20 20:17:38 +00:00
updates
This commit is contained in:
parent
d9fa642647
commit
ec08d15eaf
37
Dockerfile
37
Dockerfile
@ -1,33 +1,42 @@
|
||||
# Stage 1: Build Stage
|
||||
FROM node:alpine3.19 AS builder
|
||||
FROM node:current-alpine AS builder
|
||||
|
||||
WORKDIR /home/node
|
||||
COPY --chown=node:node . .
|
||||
WORKDIR /opt/app
|
||||
COPY . .
|
||||
|
||||
RUN apk update \
|
||||
&& apk add --no-cache bash \
|
||||
&& chmod +x /home/node/start.sh \
|
||||
&& chmod +x /opt/app/start.sh \
|
||||
&& npm install -g yarn@latest --force \
|
||||
&& yarn install --flat --production --no-cache \
|
||||
&& yarn build --no-cache \
|
||||
&& rm -rf /home/node/node_modules \
|
||||
&& rm -rf /opt/app/node_modules \
|
||||
&& rm -rf /opt/app/server/node_modules \
|
||||
&& yarn cache clean \
|
||||
&& yarn autoclean --force
|
||||
|
||||
# Stage 2: Production Stage
|
||||
FROM node:alpine3.19
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /home/node
|
||||
COPY --from=builder /home/node .
|
||||
WORKDIR /opt/app
|
||||
|
||||
COPY --from=builder /opt/app/client/dist /opt/app/client/dist
|
||||
COPY --from=builder /opt/app/server /opt/app/server
|
||||
COPY package.json /opt/app/package.json
|
||||
COPY default.conf /etc/nginx/http.d/
|
||||
COPY start.sh /opt/app/start.sh
|
||||
|
||||
|
||||
|
||||
|
||||
RUN apk add --no-cache nginx yarn openssl && \
|
||||
chmod +x /opt/app/start.sh
|
||||
|
||||
RUN apk add --no-cache curl nginx openssl && \
|
||||
rm /etc/nginx/http.d/default.conf && \
|
||||
mv /home/node/default.conf /etc/nginx/http.d/ && \
|
||||
chmod +x /home/node/start.sh
|
||||
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 \
|
||||
CMD [ "curl", "-f", "http://localhost:3001", "||", "exit", "1" ]
|
||||
|
||||
CMD ["/home/node/start.sh"]
|
||||
CMD ["/opt/app/start.sh"]
|
||||
|
||||
STOPSIGNAL SIGTERM
|
@ -1,13 +1,15 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Copy } from 'react-feather';
|
||||
import { Clipboard } from 'react-feather'; // Import Clipboard icon for the copy button
|
||||
import { Tooltip } from 'react-tooltip';
|
||||
|
||||
const RoomLink = ({ roomId, translations }) => {
|
||||
const [currentRoomId, setCurrentRoomId] = React.useState(roomId);
|
||||
const [showTooltip, setShowTooltip] = React.useState(false);
|
||||
const [tooltipMessage, setTooltipMessage] = React.useState('');
|
||||
const mountedRef = React.useRef(true);
|
||||
|
||||
const roomUrl = `${window.location.origin}/${roomId}`;
|
||||
const roomUrl = `${window.location.origin}/${currentRoomId}`;
|
||||
|
||||
React.useEffect(() => {
|
||||
mountedRef.current = true;
|
||||
@ -16,8 +18,9 @@ const RoomLink = ({ roomId, translations }) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleClick = async () => {
|
||||
const handleCopyClick = async () => {
|
||||
await navigator.clipboard.writeText(roomUrl);
|
||||
setTooltipMessage(translations.copyButtonTooltip);
|
||||
setShowTooltip(true);
|
||||
setTimeout(() => {
|
||||
if (mountedRef.current) {
|
||||
@ -26,7 +29,16 @@ const RoomLink = ({ roomId, translations }) => {
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
const handleRefreshClick = () => {
|
||||
window.location.href = roomUrl; // Reload the page with the current room URL
|
||||
};
|
||||
|
||||
const handleRoomIdChange = (e) => {
|
||||
setCurrentRoomId(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form>
|
||||
<div className="form-group">
|
||||
<div className="input-group">
|
||||
@ -37,15 +49,15 @@ const RoomLink = ({ roomId, translations }) => {
|
||||
data-testid="copy-room-button"
|
||||
className="copy-room btn btn-secondary"
|
||||
type="button"
|
||||
onClick={handleClick}
|
||||
onClick={handleCopyClick}
|
||||
>
|
||||
<Copy />
|
||||
<Clipboard />
|
||||
</button>
|
||||
</div>
|
||||
{showTooltip && (
|
||||
<Tooltip
|
||||
anchorId="copy-room"
|
||||
content={translations.copyButtonTooltip}
|
||||
content={tooltipMessage}
|
||||
place="top"
|
||||
events={[]}
|
||||
isOpen={true}
|
||||
@ -54,6 +66,31 @@ const RoomLink = ({ roomId, translations }) => {
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div className="form-group mt-3">
|
||||
<label htmlFor="current-room-id">Change Room ID</label>
|
||||
<div className="input-group">
|
||||
<input
|
||||
id="current-room-id"
|
||||
className="form-control"
|
||||
type="text"
|
||||
value={currentRoomId}
|
||||
onChange={handleRoomIdChange}
|
||||
/>
|
||||
<div className="input-group-append">
|
||||
<button
|
||||
id="refresh-room-id"
|
||||
data-testid="refresh-room-id-button"
|
||||
className="btn btn-primary" // Change button class for visibility
|
||||
type="button"
|
||||
onClick={handleRefreshClick}
|
||||
>
|
||||
Go {/* Replace icon with text */}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name localhost;
|
||||
ssl_certificate /home/node/certs/selfsigned.crt;
|
||||
ssl_certificate_key /home/node/certs/selfsigned.key;
|
||||
ssl_certificate /opt/app/certs/selfsigned.crt;
|
||||
ssl_certificate_key /opt/app/certs/selfsigned.key;
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '3.0'
|
||||
|
||||
services:
|
||||
darkwire:
|
||||
build: .
|
||||
@ -9,7 +9,7 @@ services:
|
||||
- VITE_API_HOST=localhost
|
||||
- VITE_API_PROTOCOL=http
|
||||
- VITE_COMMIT_SHA=some_sha
|
||||
- VITE_MAX_FILE_SIZE=4
|
||||
- VITE_MAX_FILE_SIZE=20
|
||||
- MAILGUN_API_KEY=api-key
|
||||
- MAILGUN_DOMAIN=darkwire.io
|
||||
- ABUSE_TO_EMAIL_ADDRESS=abuse@darkwire.io
|
||||
@ -21,7 +21,7 @@ services:
|
||||
networks:
|
||||
- db
|
||||
ports:
|
||||
- 3001:80
|
||||
- 3002:80
|
||||
- 4001:443
|
||||
- 5001:3001
|
||||
|
||||
|
25
start.sh
25
start.sh
@ -1,6 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# We use this file to translate environmental variables to .env files used by the application
|
||||
set_env() {
|
||||
echo "
|
||||
@ -52,8 +51,26 @@ generate_self_signed_ssl() {
|
||||
echo "Certificate signing request: $csr_file"
|
||||
}
|
||||
|
||||
# Graceful shutdown function
|
||||
shutdown_nginx() {
|
||||
echo "Shutting down Nginx..."
|
||||
nginx -s quit
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Trap SIGTERM signal and call shutdown_nginx
|
||||
trap 'shutdown_nginx' SIGTERM
|
||||
|
||||
set_env &&
|
||||
# Start your application
|
||||
generate_self_signed_ssl &&
|
||||
nginx &&
|
||||
yarn start #&
|
||||
generate_self_signed_ssl generate_self_signed_ssl >> /dev/null 2>&1
|
||||
|
||||
|
||||
# Start the server
|
||||
cd server
|
||||
yarn install
|
||||
cd ..
|
||||
yarn start &&
|
||||
nginx &
|
||||
# Wait indefinitely to handle SIGTERM
|
||||
wait
|
||||
|
Loading…
x
Reference in New Issue
Block a user