Skip to content

Commit 5c16c87

Browse files
committed
feat: move from yarn to pnpm, optimize Dockerfile, update docs
1 parent 66af007 commit 5c16c87

File tree

7 files changed

+8053
-6216
lines changed

7 files changed

+8053
-6216
lines changed

README.md

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,82 @@
1-
# Nuxt Minimal Starter
2-
3-
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4-
5-
## Setup
6-
7-
Make sure to install dependencies:
8-
9-
```bash
10-
# npm
11-
npm install
12-
13-
# pnpm
14-
pnpm install
15-
16-
# yarn
17-
yarn install
18-
19-
# bun
20-
bun install
1+
## Broker-agnostic admin pangel for Taskiq
2+
3+
Tasks Page | Task Details Page
4+
:-------------------------:|:-------------------------:
5+
![Alt text](./docs/images/preview1.png) | ![Alt text](./docs/images/preview2.png)
6+
7+
### Usage
8+
9+
1) Add this middleware to your taskiq broker:
10+
11+
```python
12+
from typing import Any
13+
from datetime import datetime, UTC
14+
15+
import httpx
16+
from taskiq import TaskiqMiddleware, TaskiqResult, TaskiqMessage
17+
18+
TASKIQ_ADMIN_URL = "..." # or your env vars from .env
19+
TASKIQ_ADMIN_API_TOKEN = "..." # or your env vars from .env
20+
21+
22+
class TaskiqAdminMiddleware(TaskiqMiddleware):
23+
async def pre_execute(self, message: TaskiqMessage):
24+
""""""
25+
26+
async with httpx.AsyncClient() as client:
27+
await client.post(
28+
headers={"access-token": TASKIQ_ADMIN_API_TOKEN},
29+
url=f"{TASKIQ_ADMIN_URL}/tasks/{message.task_id}/started",
30+
json={
31+
"worker": "WIP",
32+
"args": message.args,
33+
"kwargs": message.kwargs,
34+
"taskName": message.task_name,
35+
"startedAt": datetime.now(UTC)
36+
.replace(tzinfo=None)
37+
.isoformat(),
38+
},
39+
)
40+
41+
return super().pre_execute(message)
42+
43+
async def post_execute(
44+
self,
45+
message: TaskiqMessage,
46+
result: TaskiqResult[Any],
47+
):
48+
""""""
49+
50+
async with httpx.AsyncClient() as client:
51+
await client.post(
52+
headers={"access-token": TASKIQ_ADMIN_API_TOKEN},
53+
url=f"{TASKIQ_ADMIN_URL}/tasks/{message.task_id}/executed",
54+
json={
55+
"error": result.error
56+
if result.error is None
57+
else repr(result.error),
58+
"result": result.return_value,
59+
"returnValue": result.return_value,
60+
"executionTime": result.execution_time,
61+
"finishedAt": datetime.now(UTC)
62+
.replace(tzinfo=None)
63+
.isoformat(),
64+
},
65+
)
66+
67+
return super().post_execute(message, result)
2168
```
2269

23-
## Development Server
24-
25-
Start the development server on `http://localhost:3000`:
70+
2) Pull the image from DockerHub: `docker pull artur10/taskiq-admin:1.0.0`
2671

72+
3) Replace `ACCESS_TOKEN` with any secret enough string and run:
2773
```bash
28-
# npm
29-
npm run dev
30-
31-
# pnpm
32-
pnpm dev
33-
34-
# yarn
35-
yarn dev
36-
37-
# bun
38-
bun run dev
39-
```
40-
41-
## Production
42-
43-
Build the application for production:
44-
45-
```bash
46-
# npm
47-
npm run build
48-
49-
# pnpm
50-
pnpm build
51-
52-
# yarn
53-
yarn build
54-
55-
# bun
56-
bun run build
57-
```
58-
59-
Locally preview production build:
60-
61-
```bash
62-
# npm
63-
npm run preview
64-
65-
# pnpm
66-
pnpm preview
67-
68-
# yarn
69-
yarn preview
70-
71-
# bun
72-
bun run preview
74+
docker run -d --rm \
75+
-e ACCESS_TOKEN=supersecret \
76+
-p "3000:3000" \
77+
-v ./taskiq-admin-data/:/usr/database/ \
78+
--name taskiq-admin \
79+
artur10/taskiq-admin:1.0.0
7380
```
7481

75-
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
82+
4) Go to `http://localhost:3000/tasks`

docker/Dockerfile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,44 @@ ARG NODE_VERSION=22.12.0
22

33
FROM node:${NODE_VERSION}-slim AS build
44

5-
WORKDIR /usr/app
5+
# enable pnpm
6+
ENV PNPM_HOME="/pnpm"
7+
ENV PATH="$PNPM_HOME:$PATH"
8+
RUN corepack enable
9+
10+
WORKDIR /app
11+
12+
# install dependencies
13+
COPY ./package.json /app/
14+
COPY ./pnpm-lock.yaml /app/
15+
RUN pnpm install --shamefully-hoist
616

17+
# copy other files
718
COPY . ./
819

9-
RUN yarn install
20+
# build the app
21+
RUN pnpm run build
22+
23+
# =======================
24+
FROM node:${NODE_VERSION}-slim
25+
26+
WORKDIR /usr/app
27+
28+
# .output
29+
COPY --from=build /app/.output/ /usr/app/.output/
30+
COPY --from=build /app/entrypoint.sh /usr/app/entrypoint.sh
31+
32+
# add drizzle stuff just to push schema on start
33+
COPY --from=build /app/drizzle.config.ts /usr/app/drizzle.config.ts
34+
COPY --from=build /app/src/server/db/schema.ts /usr/app/src/server/db/schema.ts
1035

1136
EXPOSE 3000
1237
ENV HOST=0.0.0.0 NODE_ENV=production
13-
14-
RUN mkdir -p /usr/database/
1538
ENV DB_FILE_PATH=/usr/database/database.db
1639

17-
RUN yarn build
40+
RUN npm install drizzle-kit drizzle-orm dotenv better-sqlite3
41+
42+
RUN mkdir -p /usr/database/
1843
RUN chmod +x /usr/app/entrypoint.sh
1944

2045
CMD [ "/usr/app/entrypoint.sh" ]

docs/images/preview1.png

242 KB
Loading

docs/images/preview2.png

57.1 KB
Loading

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "nuxt-app",
33
"private": true,
44
"type": "module",
5+
"version": "1.0.0",
56
"scripts": {
67
"build": "nuxt build",
78
"dev": "nuxt dev",
@@ -20,9 +21,9 @@
2021
"vue-router": "^4.5.0",
2122
"zod": "^3.23.8"
2223
},
23-
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447",
24+
"packageManager": "[email protected]+sha1.a428b12202bc4f23b17e6dffe730734dae5728e2",
2425
"devDependencies": {
2526
"@nuxtjs/tailwindcss": "^6.12.2",
2627
"@types/better-sqlite3": "^7.6.12"
2728
}
28-
}
29+
}

0 commit comments

Comments
 (0)