-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker improvements #5946
Docker improvements #5946
Changes from 13 commits
27c7793
8aa81b1
bf3b6ce
7f31eac
b804890
5c3638d
7ae2748
6fb39ef
6760a69
0d24af7
e41f5e2
b4c3103
9b0c7bf
ecc57d6
5eba8a1
dbe6f4c
18f9097
cf75152
1894774
f7c3bae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
icon_cache | ||
logs | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
TZ="UTC" | ||
ROBOCHIMP_DATABASE_URL="postgresql://postgres:postgres@localhost:5435/robochimp_integration_test?connection_limit=500&pool_timeout=0&schema=public" | ||
DATABASE_URL="postgresql://postgres:postgres@localhost:5435/osb_integration_test?connection_limit=500&pool_timeout=0&schema=public" | ||
CLIENT_ID=111398433321891634 | ||
BOT_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | ||
TEST=true | ||
TEST=true | ||
CI=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
services: | ||
osb: | ||
db: | ||
image: postgres:16-alpine | ||
command: -c 'max_connections=1000' | ||
restart: always | ||
container_name: osb_database | ||
ports: | ||
- "5435:3001" | ||
- "5435:5435" | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
PGPORT: 3001 | ||
PGPORT: 5435 | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
|
||
app: | ||
build: | ||
context: . | ||
args: | ||
GIT_BRANCH: ${GIT_BRANCH} | ||
depends_on: | ||
- db | ||
environment: | ||
ROBOCHIMP_DATABASE_URL: postgresql://postgres:postgres@db:5435/robochimp_integration_test?connection_limit=500&pool_timeout=0&schema=public | ||
DATABASE_URL: postgresql://postgres:postgres@db:5435/osb_integration_test?connection_limit=500&pool_timeout=0&schema=public | ||
WAIT_HOSTS: db:5435 | ||
|
||
volumes: | ||
postgres_data: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM node:20.15.0-alpine AS base | ||
WORKDIR /usr/src/app | ||
ENV CI=true | ||
RUN apk add --no-cache dumb-init python3 g++ make git | ||
RUN corepack enable | ||
|
||
COPY yarn.lock package.json .yarnrc.yml ./ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the |
||
|
||
ENTRYPOINT ["dumb-init", "--"] | ||
|
||
FROM base AS dependencies | ||
WORKDIR /usr/src/app | ||
RUN yarn install --immutable | ||
|
||
FROM base AS build-run | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
WORKDIR /usr/src/app | ||
ENV NODE_ENV="development" | ||
ENV NODE_OPTIONS="--enable-source-maps --max_old_space_size=4096" | ||
|
||
COPY --from=dependencies /usr/src/app/node_modules /usr/src/app/node_modules | ||
COPY . . | ||
|
||
ENV CI=true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
RUN cp .env.test .env | ||
RUN cp src/config.example.ts src/config.ts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copying |
||
|
||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /wait | ||
RUN chmod +x /wait | ||
|
||
CMD /wait && yarn prisma db push --schema='./prisma/robochimp.prisma' && yarn prisma db push --schema='./prisma/schema.prisma' && yarn run build:tsc && yarn vitest run --config vitest.integration.config.mts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider encapsulating the commands in the CMD instruction into a script to handle potential failures more gracefully and improve maintainability. Additionally, move the TypeScript build step ( |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,10 @@ | |
"test:unit": "vitest run --coverage --config vitest.unit.config.mts", | ||
"test:watch": "vitest --config vitest.unit.config.mts --coverage", | ||
"test:integration": "tsx ./src/scripts/integration-tests.ts", | ||
"watch": "tsc -w -p src" | ||
"watch": "tsc -w -p src", | ||
"build:esbuild": "yarn build:main && yarn build:workers", | ||
"build:main": "esbuild src/index.ts --minify --legal-comments=none --bundle --outdir=./dist --platform=node --loader:.node=file --external:@napi-rs/canvas --external:@prisma/robochimp --external:@prisma/client --external:zlib-sync --external:bufferutil --external:oldschooljs --external:discord.js --external:node-fetch --external:piscina", | ||
"build:workers": "esbuild src/lib/workers/kill.worker.ts src/lib/workers/finish.worker.ts src/lib/workers/casket.worker.ts --minify --legal-comments=none --outdir=./dist/workers --platform=node --loader:.node=file --external:piscina" | ||
}, | ||
"dependencies": { | ||
"@napi-rs/canvas": "^0.1.53", | ||
|
@@ -51,6 +54,7 @@ | |
"@types/node-fetch": "^2.6.1", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"concurrently": "^8.2.2", | ||
"esbuild": "0.21.5", | ||
"fast-glob": "^3.3.2", | ||
"prettier": "^3.3.2", | ||
"prisma": "^5.16.1", | ||
|
@@ -61,5 +65,8 @@ | |
"engines": { | ||
"node": "20.15.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"esbuild": "0.21.5" | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command
docker-compose up --build --abort-on-container-exit
might not be appropriate for integration tests as it builds and runs all services, which could include non-test related services. Consider specifying only the necessary services or adjusting the docker-compose configuration to ensure only relevant services are included during the test phase.