diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4837bad --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.dockerignore +.editorconfig +.env +.git +.gitignore +.idea +.vscode +coverage* +docker-compose* +Dockerfile* +helm-charts +Justfile +LICENSE +Makefile +node_modules +README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6079610 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# use the official Bun image +# see all versions at https://hub.docker.com/r/oven/bun/tags +FROM oven/bun:1 AS base +WORKDIR /usr/src/app + +# install dependencies into temp directory +# this will cache them and speed up future builds +FROM base AS install +RUN mkdir -p /temp/dev +COPY package.json bun.lock /temp/dev/ +RUN cd /temp/dev && bun install --frozen-lockfile + +# install with --production (exclude devDependencies) +RUN mkdir -p /temp/prod +COPY package.json bun.lock /temp/prod/ +RUN cd /temp/prod && bun install --frozen-lockfile --production + +# copy node_modules from temp directory +# then copy all (non-ignored) project files into the image +FROM base AS prerelease +COPY --from=install /temp/dev/node_modules node_modules +COPY . . + +# [optional] tests & build +ENV NODE_ENV=production +# RUN bun test +# RUN bun run build + +# copy production dependencies and source code into final image +FROM base AS release +COPY --from=install /temp/prod/node_modules node_modules +COPY --from=prerelease /usr/src/app/build/index.js . +COPY --from=prerelease /usr/src/app/package.json . + +# run the app +USER bun +EXPOSE 3000/tcp +ENTRYPOINT [ "bun", "run", "index.js" ] \ No newline at end of file diff --git a/Justfile b/Justfile index 3756aff..44157c5 100644 --- a/Justfile +++ b/Justfile @@ -5,6 +5,11 @@ fmt: format: bunx --bun @biomejs/biome format --write *.ts plugins/ - lint: - bunx --bun @biomejs/biome lint --fix *.ts plugins/ \ No newline at end of file + bunx --bun @biomejs/biome lint --fix *.ts plugins/ + +docker-build: + docker build --pull -t blitzcrank:latest-dev . + +docker-run: + docker run --env-file .env blitzcrank:latest-dev \ No newline at end of file diff --git a/bun.lock b/bun.lock index 29566b4..ed0debb 100644 --- a/bun.lock +++ b/bun.lock @@ -7,6 +7,7 @@ "@biomejs/biome": "^2.0.6", "chrono-node": "^2.8.3", "discord.js": "^14.21.0", + "pg-hstore": "^2.3.4", "sequelize": "^6.37.7", "sqlite3": "^5.1.7", }, @@ -406,6 +407,8 @@ "pg-connection-string": ["pg-connection-string@2.9.1", "", {}, "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w=="], + "pg-hstore": ["pg-hstore@2.3.4", "", { "dependencies": { "underscore": "^1.13.1" } }, "sha512-N3SGs/Rf+xA1M2/n0JBiXFDVMzdekwLZLAO0g7mpDY9ouX+fDI7jS6kTq3JujmYbtNSJ53TJ0q4G98KVZSM4EA=="], + "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], "picomatch": ["picomatch@4.0.2", "", {}, "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg=="], @@ -506,6 +509,8 @@ "tunnel-agent": ["tunnel-agent@0.6.0", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w=="], + "underscore": ["underscore@1.13.7", "", {}, "sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g=="], + "undici": ["undici@6.21.3", "", {}, "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw=="], "undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="], diff --git a/package.json b/package.json index 306981d..4cdcf6d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@biomejs/biome": "^2.0.6", "chrono-node": "^2.8.3", "discord.js": "^14.21.0", + "pg-hstore": "^2.3.4", "sequelize": "^6.37.7", "sqlite3": "^5.1.7" },