Skip to content

Commit

Permalink
chore: running docker with typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-apprentice committed Sep 14, 2024
1 parent 8ed10b5 commit e4e708b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
22 changes: 7 additions & 15 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM oven/bun:1 AS base
WORKDIR /usr/src/app
WORKDIR /bun

FROM base AS install

Expand All @@ -12,21 +12,13 @@ COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

ENV NODE_ENV=production
RUN bun run lint
RUN bun run build

FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/dist ./dist
COPY src src

RUN mkdir -p /usr/src/app/src/image/assets/images
RUN chown -R bun:bun /usr/src/app/src/image/assets/images
RUN chmod -R 600 /usr/src/app/src/image/assets/images
RUN mkdir -p /bun/src/image/assets/images
RUN chmod -R 600 /bun/src/image/assets/images

ENV NODE_ENV=production
USER bun
EXPOSE 4000/tcp
ENTRYPOINT [ "bun", "dist/index.js" ]
EXPOSE 4000
CMD ["bun", "/bun/src/app/index.ts"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"author": "jd-apprentice",
"license": "MIT",
"main": "dist/app/index.js",
"main": "dist/index.js",
"type": "module",
"scripts": {
"prebuild": "rm -rf dist",
Expand Down
8 changes: 4 additions & 4 deletions src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import express from 'express';
import cors from 'cors';

// Internal Modules
import routes from './routes/index';
import { routes } from './routes/index';

// Express
const app = express();
Expand All @@ -13,8 +13,8 @@ app.use(express.urlencoded({ extended: false }));
app.use(cors());
app.use(helmet());
app.use('/api', routes);
app.use('/', (req, res) => {
res.status(200).json({ message: 'Allo! Catch-all route.' });
});
app.use('/', (req, res) =>
res.status(200).json({ message: 'Allo! Catch-all route.' }),

Check failure on line 17 in src/app/main.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/app/main.ts#L17

Unsafe return of an `any` typed value.
);

export { app };
4 changes: 1 addition & 3 deletions src/app/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import userRouter from "../../user/user-routes";
import tagRouter from "../../tag/tag-routes";
import imageRouter from "../../image/image-routes";

const routes = Router();
export const routes = Router();

routes.use("/images", imageRouter);
routes.use("/user", userRouter);
routes.use("/tags", tagRouter);
routes.use("/", (req, res) => {
res.status(200).json({ message: "Welcome to the Waifuland API" });
});

export default routes;

0 comments on commit e4e708b

Please sign in to comment.