Skip to content

Commit f4f8d87

Browse files
committed
Add dockerfiles / docker-compose file for all services
1 parent 74676cc commit f4f8d87

File tree

13 files changed

+177
-3
lines changed

13 files changed

+177
-3
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/target/
2+
/ui/node_modules
3+
/ui/.next
4+
.git
5+
/data
6+
*.log
7+
.env
8+
.env.docker
9+
/ui/.env

.github/workflows/docker.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Docker Build
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
jobs:
12+
docker-build:
13+
name: Docker Build
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- run: cp .env.example .env.docker
18+
- run: sed -i 's/localhost/host.docker.internal/g' .env.docker
19+
- run: docker compose -f docker-compose.tips.yml build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Thumbs.db
1818

1919
# Environment variables
2020
.env
21+
.env.docker
2122
/ui/.env
2223

2324
# Claude

crates/audit/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM rust:1-bookworm AS builder
2+
3+
WORKDIR /app
4+
5+
COPY Cargo.toml Cargo.lock ./
6+
COPY crates/ ./crates/
7+
8+
RUN cargo build --release --bin tips-audit
9+
10+
FROM debian:bookworm-slim
11+
12+
WORKDIR /app
13+
14+
COPY --from=builder /app/target/release/tips-audit /app/tips-audit
15+
16+
EXPOSE 3001
17+
18+
CMD ["/app/tips-audit"]

crates/ingress/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM rust:1-bookworm AS builder
2+
3+
WORKDIR /app
4+
5+
COPY Cargo.toml Cargo.lock ./
6+
COPY crates/ ./crates/
7+
COPY .sqlx/ ./.sqlx/
8+
9+
RUN cargo build --release --bin tips-ingress
10+
11+
FROM debian:bookworm-slim
12+
13+
WORKDIR /app
14+
15+
COPY --from=builder /app/target/release/tips-ingress /app/tips-ingress
16+
17+
EXPOSE 3000
18+
19+
CMD ["/app/tips-ingress"]

crates/maintenance/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM rust:1-bookworm AS builder
2+
3+
WORKDIR /app
4+
5+
COPY Cargo.toml Cargo.lock ./
6+
COPY crates/ ./crates/
7+
COPY .sqlx/ ./.sqlx/
8+
9+
RUN cargo build --release --bin tips-maintenance
10+
11+
FROM debian:bookworm-slim
12+
13+
WORKDIR /app
14+
15+
COPY --from=builder /app/target/release/tips-maintenance /app/tips-maintenance
16+
17+
CMD ["/app/tips-maintenance"]

docker-compose.tips.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
services:
2+
tips-ingress:
3+
build:
4+
context: .
5+
dockerfile: crates/ingress/Dockerfile
6+
container_name: tips-ingress
7+
ports:
8+
- "8080:8080"
9+
env_file:
10+
- .env.docker
11+
restart: unless-stopped
12+
13+
tips-audit:
14+
build:
15+
context: .
16+
dockerfile: crates/audit/Dockerfile
17+
container_name: tips-audit
18+
env_file:
19+
- .env.docker
20+
restart: unless-stopped
21+
22+
tips-maintenance:
23+
build:
24+
context: .
25+
dockerfile: crates/maintenance/Dockerfile
26+
container_name: tips-maintenance
27+
env_file:
28+
- .env.docker
29+
restart: unless-stopped
30+
31+
tips-ui:
32+
build:
33+
context: .
34+
dockerfile: ui/Dockerfile
35+
ports:
36+
- "3000:3000"
37+
container_name: tips-ui
38+
env_file:
39+
- .env.docker
40+
restart: unless-stopped

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,4 @@ services:
8787
/usr/bin/mc mb minio/tips;
8888
/usr/bin/mc anonymous set public minio/tips;
8989
exit 0;
90-
"
91-
90+
"

justfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@ sync: deps-reset
2727
cd ui && mv ./drizzle/schema.ts ./src/db/
2828
cd ui && rm -rf ./drizzle
2929
### ENV ###
30+
just sync-env
31+
### REFORMAT ###
32+
just fix
33+
34+
sync-env:
3035
cp .env.example .env
3136
cp .env.example ./ui/.env
37+
cp .env.example .env.docker
38+
sed -i '' 's/localhost/host.docker.internal/g' ./.env.docker
39+
40+
start-all:
41+
export COMPOSE_FILE=docker-compose.yml:docker-compose.tips.yml && docker compose down && docker compose rm && docker compose build && rm -rf data/ && mkdir -p data/postgres data/kafka data/minio && docker compose up -d
3242

3343
### RUN SERVICES ###
3444
deps-reset:

ui/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:20-alpine AS deps
2+
WORKDIR /app
3+
COPY ui/package.json ui/yarn.lock ./
4+
RUN yarn install --frozen-lockfile
5+
6+
FROM node:20-alpine AS builder
7+
WORKDIR /app
8+
COPY --from=deps /app/node_modules ./node_modules
9+
COPY ./ui .
10+
11+
ENV NEXT_TELEMETRY_DISABLED=1
12+
13+
RUN yarn build
14+
15+
FROM node:20-alpine AS runner
16+
WORKDIR /app
17+
18+
ENV NODE_ENV=production
19+
ENV NEXT_TELEMETRY_DISABLED=1
20+
21+
RUN addgroup --system --gid 1001 nodejs
22+
RUN adduser --system --uid 1001 nextjs
23+
24+
COPY --from=builder /app/public ./public
25+
26+
RUN mkdir .next
27+
RUN chown nextjs:nodejs .next
28+
29+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
30+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
31+
32+
USER nextjs
33+
34+
EXPOSE 3000
35+
36+
ENV PORT=3000
37+
ENV HOSTNAME="0.0.0.0"
38+
39+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)