Skip to content

Commit 10ecf03

Browse files
committed
update docker implementation
1 parent 1434e3b commit 10ecf03

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules
2+
bun.lock
3+
4+
.vscode/
5+
6+
.git/
7+
.github/
8+
.gitignore
9+
10+
dist/
11+
tests/
12+
*.md
13+
14+
.eslintcache

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM oven/bun:alpine AS builder
1+
FROM oven/bun:1.2.19-alpine AS builder
22
WORKDIR /app
33

44
COPY ./package.json ./bun.lock ./
@@ -7,7 +7,7 @@ RUN bun install --frozen-lockfile
77
COPY . .
88
RUN bun run build
99

10-
FROM oven/bun:alpine AS runner
10+
FROM oven/bun:1.2.19-alpine AS runner
1111
WORKDIR /app
1212

1313
COPY ./package.json ./bun.lock ./
@@ -17,7 +17,11 @@ COPY --from=builder /app/dist ./dist
1717

1818
EXPOSE 4141
1919

20+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
21+
CMD wget --spider -q http://localhost:4141/ || exit 1
22+
2023
ARG GH_TOKEN
2124
ENV GH_TOKEN=$GH_TOKEN
2225

23-
CMD bun run dist/main.js start -g $GH_TOKEN
26+
ENTRYPOINT ["bun", "run", "dist/main.js"]
27+
CMD ["start", "-g", "$GH_TOKEN"]

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,41 @@ Run the container
5757
docker run -p 4141:4141 copilot-api
5858
```
5959

60+
### Docker with Environment Variables
61+
62+
You can pass the GitHub token directly to the container using environment variables:
63+
64+
```sh
65+
# Build with GitHub token
66+
docker build --build-arg GH_TOKEN=your_github_token_here -t copilot-api .
67+
68+
# Run with GitHub token
69+
docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here copilot-api
70+
71+
# Run with additional options
72+
docker run -p 4141:4141 -e GH_TOKEN=your_token copilot-api start --verbose --port 4141
73+
```
74+
75+
### Docker Compose Example
76+
77+
```yaml
78+
version: '3.8'
79+
services:
80+
copilot-api:
81+
build: .
82+
ports:
83+
- "4141:4141"
84+
environment:
85+
- GH_TOKEN=your_github_token_here
86+
restart: unless-stopped
87+
```
88+
89+
The Docker image includes:
90+
- Multi-stage build for optimized image size
91+
- Non-root user for enhanced security
92+
- Health check for container monitoring
93+
- Pinned base image version for reproducible builds
94+
6095
## Using with npx
6196
6297
You can run the project directly using npx:

0 commit comments

Comments
 (0)