Skip to content

Commit

Permalink
Cleanup migrate script & Add messages.room_id SQL index & Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
7PH committed Feb 4, 2024
1 parent 0a97bbb commit 65fc8db
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2,149 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ RUN ln -snf /usr/share/zoneinfo/$DOCKER_TZ /etc/localtime && \
# Copy build configuration
COPY .env.json package*.json *config\.* ./

# Copy source files
COPY ./app ./app
# Install dependencies
RUN npm ci --ignore-scripts

# Change files permissions
RUN chown -R $DOCKER_UID:$DOCKER_GID ./

# Change to non-root privilege
USER $DOCKER_UID:$DOCKER_GID

# Install dependencies
RUN npm ci && \
npm run build
# Copy source files
COPY ./app ./app

# Build
RUN npm run build

# Expose app port
EXPOSE $DOCKER_PORT
Expand Down
3 changes: 0 additions & 3 deletions app/database/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ ARG DOCKER_USER
ARG DOCKER_UID
ARG DOCKER_GID

# Install pgloader (needed for migration from sqlite)
RUN apk --update add pgloader

# Change workdir
WORKDIR /app

Expand Down
3 changes: 3 additions & 0 deletions app/script/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker compose up --build -d
102 changes: 0 additions & 102 deletions app/server/migrate.ts

This file was deleted.

2 changes: 2 additions & 0 deletions app/server/skychat/DatabaseHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ CREATE TABLE IF NOT EXISTS messages (
ip text DEFAULT NULL
);
-- Add index on room_id and id in descending order, if it doesn't exist
CREATE INDEX IF NOT EXISTS room_id_id_index ON messages (room_id, id DESC);
`;

/**
Expand Down
4 changes: 2 additions & 2 deletions app/server/skychat/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from 'lodash';
import _ from 'lodash';
import sha256 from 'sha256';
import { Config } from './Config';
import { DatabaseHelper } from './DatabaseHelper';
Expand All @@ -11,7 +11,7 @@ export class UserController {
/**
* Validity of the auth token in seconds
*/
public static AUTH_TOKEN_VALIDITY: number = 1000 * 60 * 60 * 24 * 7;
public static readonly AUTH_TOKEN_VALIDITY: number = 1000 * 60 * 60 * 24 * 7;

/**
*
Expand Down
Loading

0 comments on commit 65fc8db

Please sign in to comment.