feat: Contanerization via Docker & Docker Compose
This commit is contained in:
parent
f4fda50135
commit
bb2a0787b1
42
.dockerignore
Normal file
42
.dockerignore
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/.next
|
||||||
|
**/.cache
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/compose.y*ml
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
**/build
|
||||||
|
**/dist
|
||||||
|
**/src/lib/server/db/users.db*
|
||||||
|
**/minio-storage
|
||||||
|
**/vite.config.js.timestamp-*
|
||||||
|
**/vite.config.ts.timestamp-*
|
||||||
|
.output
|
||||||
|
.vercel
|
||||||
|
.netlify
|
||||||
|
.wrangler
|
||||||
|
/.svelte-kit
|
||||||
|
/build
|
||||||
|
/drizzle
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
LICENSE
|
||||||
|
README.md
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -28,7 +28,7 @@ vite.config.js.timestamp-*
|
|||||||
vite.config.ts.timestamp-*
|
vite.config.ts.timestamp-*
|
||||||
|
|
||||||
# Sqlite
|
# Sqlite
|
||||||
src/lib/server/db/users.db*
|
**/src/lib/server/db/users.db*
|
||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
minio-storage
|
**/minio-storage
|
||||||
|
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
ARG NODE_VERSION=23.8.0
|
||||||
|
FROM node:${NODE_VERSION} AS base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
###############
|
||||||
|
# Dep Stage #
|
||||||
|
###############
|
||||||
|
FROM base AS deps
|
||||||
|
COPY package.json .
|
||||||
|
|
||||||
|
RUN npm install --omit-dev
|
||||||
|
|
||||||
|
###############
|
||||||
|
# Build Stage #
|
||||||
|
###############
|
||||||
|
FROM deps AS build
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Run DB migrations for SQLite
|
||||||
|
RUN npm run migrate
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
###############
|
||||||
|
# Application #
|
||||||
|
###############
|
||||||
|
FROM base AS final
|
||||||
|
|
||||||
|
COPY package.json .
|
||||||
|
|
||||||
|
# Stuff needed by the app
|
||||||
|
COPY --from=build /app/build build/
|
||||||
|
COPY --from=build /app/prodServer.ts .
|
||||||
|
COPY --from=build /app/package.json .
|
||||||
|
COPY --from=build /app/src/lib/server/db src/lib/server/db
|
||||||
|
COPY --from=deps /app/node_modules node_modules/
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["npm", "run", "production"]
|
2
TODO.md
2
TODO.md
@ -5,7 +5,7 @@ A more complex version of this list is available [here](https://trello.com/b/kJw
|
|||||||
|
|
||||||
- [x] Account / Profile management
|
- [x] Account / Profile management
|
||||||
- [ ] Channel context menus
|
- [ ] Channel context menus
|
||||||
- [ ] Containerization with docker and docker-compose
|
- [X] Containerization with docker and docker-compose
|
||||||
- [ ] Documentation
|
- [ ] Documentation
|
||||||
- [ ] Emoji picker
|
- [ ] Emoji picker
|
||||||
- [ ] Images/Attatchments support
|
- [ ] Images/Attatchments support
|
||||||
|
49
compose.yaml
Normal file
49
compose.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
services:
|
||||||
|
chat-server:
|
||||||
|
container_name: svchat-server
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
environment:
|
||||||
|
NODE_ENV: docker_production
|
||||||
|
ORIGIN: http://localhost:3000
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
depends_on:
|
||||||
|
- cassandra
|
||||||
|
volumes:
|
||||||
|
- svchat-users:/app/src/lib/server/db
|
||||||
|
|
||||||
|
cassandra:
|
||||||
|
container_name: svchat-db
|
||||||
|
image: cassandra
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 9042:9042
|
||||||
|
environment:
|
||||||
|
# TODO Change default passwords
|
||||||
|
- CASSANDRA_USER=admin
|
||||||
|
- CASSANDRA_PASSWORD=admin
|
||||||
|
volumes:
|
||||||
|
- svchat-cassandra:/var/lib/cassandra
|
||||||
|
|
||||||
|
minio:
|
||||||
|
container_name: svchat-s3
|
||||||
|
image: docker.io/bitnami/minio
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 9000:9000
|
||||||
|
- 9001:9001
|
||||||
|
environment:
|
||||||
|
# TODO Change default passwords
|
||||||
|
- MINIO_ROOT_USER=minioadmin
|
||||||
|
- MINIO_ROOT_PASSWORD=minioadmin
|
||||||
|
volumes:
|
||||||
|
- svchat-s3:/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
svchat-cassandra:
|
||||||
|
driver: local
|
||||||
|
svchat-s3:
|
||||||
|
driver: local
|
||||||
|
svchat-users:
|
||||||
|
driver: local
|
@ -11,7 +11,7 @@
|
|||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"migrate": "npx @better-auth/cli migrate --config './src/lib/server/db/auth'",
|
"migrate": "npx @better-auth/cli migrate --config './src/lib/server/db/auth' -y",
|
||||||
"minio": "minio server minio-storage",
|
"minio": "minio server minio-storage",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"prepare": "svelte-kit sync || echo ''",
|
"prepare": "svelte-kit sync || echo ''",
|
||||||
|
@ -9,6 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
const app = express();
|
const app = express();
|
||||||
const server = createServer(app);
|
const server = createServer(app);
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
|
const port = 3000;
|
||||||
|
|
||||||
io.on('connection', async (socket) => {
|
io.on('connection', async (socket) => {
|
||||||
// Runs on client connection
|
// Runs on client connection
|
||||||
@ -44,6 +45,6 @@ app.use((req, res, next) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(3005, () => {
|
server.listen(port, () => {
|
||||||
console.log('Listening on http://0.0.0.0:3005');
|
console.log(`Listening on http://localhost:${port}`);
|
||||||
});
|
});
|
||||||
|
@ -18,9 +18,11 @@ function sanitizeChannelName(channelName: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Db {
|
class Db {
|
||||||
|
private clientUrl: string = process.env.NODE_ENV === 'docker_production' ? 'cassandra' : 'localhost';
|
||||||
private client: cassandra.Client = new cassandra.Client({
|
private client: cassandra.Client = new cassandra.Client({
|
||||||
contactPoints: ['localhost'],
|
contactPoints: [this.clientUrl],
|
||||||
localDataCenter: 'datacenter1',
|
localDataCenter: 'datacenter1',
|
||||||
|
authProvider: new cassandra.auth.PlainTextAuthProvider('admin', 'admin'),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initalize and connect
|
// Initalize and connect
|
||||||
|
@ -71,7 +71,8 @@ let fsClient: MinioClient | undefined;
|
|||||||
|
|
||||||
if (process.env.BUILDING !== 'true') {
|
if (process.env.BUILDING !== 'true') {
|
||||||
fsClient = new MinioClient({
|
fsClient = new MinioClient({
|
||||||
endPoint: 'localhost',
|
// Endpoint is 'minio' in compose, 'localhost' everywhere else
|
||||||
|
endPoint: process.env.NODE_ENV === 'docker_production' ? 'minio' : 'localhost',
|
||||||
port: 9000,
|
port: 9000,
|
||||||
accessKey: 'minioadmin',
|
accessKey: 'minioadmin',
|
||||||
secretKey: 'minioadmin',
|
secretKey: 'minioadmin',
|
||||||
|
Loading…
Reference in New Issue
Block a user