Skip to content

Commit 43c3194

Browse files
* Fix occasional "missing car" for /carsized
* Improved README.md * Improve build process * Updated dependencies
1 parent 60d6caf commit 43c3194

File tree

11 files changed

+338
-400
lines changed

11 files changed

+338
-400
lines changed

.dockerignore

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
1-
/.env
2-
/LICENSE
3-
/README.md
4-
/build
5-
/dump.sql
6-
/flyway
7-
8-
# Docker
9-
/.dockerignore
10-
/Dockerfile
11-
/docker-compose.yml
12-
13-
# Git
14-
/.git
15-
/.gitignore
16-
17-
# GitHub
18-
/.github
19-
20-
# JetBrains
21-
/.idea
22-
23-
# Node.js
24-
/node_modules
25-
26-
# Prettier
27-
/.prettierignore
1+
# Ignore everything
2+
**
3+
# except
4+
!/src
5+
!/.eslint*
6+
!/package*.json
7+
!/tsconfig.json

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# ESLint
2-
/.eslintrc.js
1+
**/*.js

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
"plugin:sonarjs/recommended",
88
"plugin:unicorn/recommended",
99
],
10-
ignorePatterns: ["/build/*"],
1110
parserOptions: {
1211
ecmaVersion: "latest",
1312
parser: "@typescript-eslint/parser",

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/.env
1+
/.env*
22
/build
33
/dump.sql
44

.prettierignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

Dockerfile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
FROM node:20.8.0
2-
1+
FROM node:20.8.0 as base
32
WORKDIR /pedestrian
4-
5-
# Express port
6-
EXPOSE 8080
7-
83
# Install Chrome dependencies for puppeteer
94
RUN apt-get update \
105
&& apt-get install -y wget gnupg \
@@ -20,17 +15,26 @@ RUN apt-get update \
2015
&& mkdir -p /home/pptruser/Downloads \
2116
&& chown -R pptruser:pptruser /home/pptruser \
2217
&& chown -R pptruser:pptruser /pedestrian
23-
24-
# Run everything after as puppeteer
18+
# Use puppeteer user for Chrome sandbox
2519
USER pptruser
26-
2720
COPY package*.json ./
2821

22+
FROM base as build
23+
# Install runtime and build dependencies
2924
RUN npm ci
30-
25+
# Copy source code into current image
3126
COPY . .
32-
33-
RUN npm run check \
27+
# Test source code
28+
RUN npm test \
29+
# Build source code
3430
&& npm run build
3531

32+
FROM base
33+
# Install runtime dependencies
34+
RUN npm ci --omit=dev
35+
# Copy built source code into current image
36+
COPY --from=build /pedestrian/build ./build
37+
# Expose port used by Express
38+
EXPOSE 8080
39+
3640
CMD npm run production

README.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,20 @@ A custom bot designed for [The Anti-Car Collective](https://discord.gg/anticar)
44

55
## Development
66

7-
[Node.js](https://nodejs.org) and [docker-compose](https://docs.docker.com/compose) is required for development.
7+
### Requirements
88

9-
Required [environment variables](#environment-variables) must be configured in a `.env` file at the project's root to start (`npm run start`).
10-
11-
It is recommended to dump (`npm run dump`) the database before migrating (`npm run migrate`) in case restoring (`npm run restore`) is required.
12-
13-
Code must pass minimum quality standards checks (`npm run check`) to be merged:
14-
15-
- [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) must not emit any errors
16-
- [ESLint](https://eslint.org) must not emit any errors
17-
- Must be formatted with [Prettier](https://prettier.io) (`npm run prettier`)
9+
- [Node.js](https://nodejs.org)
10+
- [docker-compose](https://docs.docker.com/compose)
1811

1912
### Environment Variables
2013

14+
Required environment variables must be configured in a `.env` file at the project's root. While [debugging](#debugging), additional environment variables can be configured in a `.env.debug` file at the project's root; for example, setting `REDIS_HOST` and `POSTGRESQL_HOST` to `localhost` is a common debug requirement.
15+
2116
| Environment Variable | Required | Default Value | Notes |
2217
| -------------------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------ |
2318
| BOT_GUILD_ID || | Guild ID to enable `/bot` |
2419
| DISCORD_TOKEN || | [Create Discord Token](https://discord.com/developers/docs/getting-started#configuring-your-bot) |
25-
| ENABLE_CARSIZED || false | IIF value is "true" then `/carsized` is enabled |
20+
| ENABLE_CARSIZED || | IIF value is `true` then `/carsized` is enabled |
2621
| EXPRESS_PORT || 8080 | |
2722
| POSTGRESQL_HOST || postgres | |
2823
| POSTGRESQL_PORT || 5432 | |
@@ -32,7 +27,32 @@ Code must pass minimum quality standards checks (`npm run check`) to be merged:
3227
| PROJECT_NAME || Pedestrian | |
3328
| REDIS_HOST || redis | |
3429
| REDIS_PORT || 6379 | |
35-
| REDIS_CLUSTER || false | IIF value is "true" then Redis will run in [cluster mode](https://redis.io/docs/management/scaling/) |
30+
| REDIS_CLUSTER || | IIF value is `true` then Redis will run in [cluster mode](https://redis.io/docs/management/scaling/) |
3631
| REDIS_USERNAME || | |
3732
| REDIS_PASSWORD || | |
3833
| YOUTUBE_API_KEY || | [Create YouTube API Key](https://console.cloud.google.com/apis/api/youtube.googleapis.com/credentials) |
34+
35+
### Quick Start
36+
37+
Simply run `npm start`! Assuming the above requirements are met, the project will automatically be built and deployed locally along with required dependencies and services.
38+
39+
### Debugging
40+
41+
Steps 1-3 is not required if the ask is already installed, updated, and/or running.
42+
43+
1. Run third-party services (`npm run services`)
44+
2. Install dependencies (`npm install`)
45+
3. Build project (`npm run build`)
46+
4. Attach debugger while running `npm run debug`
47+
48+
### Database Migration
49+
50+
It is recommended to dump (`npm run dump`) the database before migrating (`npm run migrate`) in case restoring (`npm run restore`) is required.
51+
52+
### Pull Requests
53+
54+
Tests (`npm test`) must pass for any changes to be merged:
55+
56+
- [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) must not emit any errors
57+
- [ESLint](https://eslint.org) must not emit any errors
58+
- Must be formatted with [Prettier](https://prettier.io) (`npm run prettier`)

0 commit comments

Comments
 (0)