Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@

FROM openapitools/openapi-generator-cli:v7.18.0 AS generate

COPY ./openapi-spec ./openapi-spec

RUN openapi-generator-cli generate -i ./openapi-spec/openapi.yaml -g rust-axum -o /local/openapi
RUN openapi-generator-cli generate \
-i ./openapi-spec/openapi.yaml \
-g rust-axum \
-o /local/openapi

FROM lukemathwalker/cargo-chef:0.1.75-rust-1.93.1 AS chef
WORKDIR /app/backend

FROM rust:1.92.0-alpine3.23

RUN cargo install cargo-watch
FROM chef AS planner

RUN apk add --no-cache curl
COPY ./app/backend .
COPY --from=generate /local/openapi ./openapi

COPY ./app/backend /app/backend
RUN cargo chef prepare --recipe-path recipe.json

COPY --from=generate /local/openapi /app/backend/openapi

WORKDIR /app/backend
FROM chef AS builder

COPY --from=planner /app/backend/recipe.json recipe.json

COPY --from=generate /local/openapi ./openapi

RUN cargo chef cook --recipe-path recipe.json

COPY ./app/backend .

RUN cargo build --bin backend

FROM debian:trixie-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder /app/backend/target/debug/backend /usr/local/bin/backend

RUN cargo build --release
ENTRYPOINT ["/usr/local/bin/backend"]

CMD ["cargo", "watch", "-x", "run --release"]
2 changes: 1 addition & 1 deletion Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ COPY ./app/frontend .

COPY ./openapi-spec ./openapi-spec

RUN API_SPEC=./openapi-spec/openapi.yaml API_URL=backend:8080 bun i
RUN API_SPEC=./openapi-spec/openapi.yaml bun i
9 changes: 8 additions & 1 deletion app/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ To generate the code, run:
API_SPEC=../../openapi.yaml bun i
```

This will install dependencies and generate the API client code.
This will install dependencies.
Then, run:

```bash
API_SPEC=../../openapi.yaml bun run setup
```

This will generate the code from the OpenAPI spec and set up any necessary configuration.
6 changes: 3 additions & 3 deletions app/frontend/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions app/frontend/lib/dev-axios-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import axios, { AxiosRequestConfig } from "axios";

const baseUrl = import.meta.env.SSR ? "http://backend:8080" : "http://localhost:8080";

export const apiClient = axios.create();

export const myAxios = (config: AxiosRequestConfig) => {
return apiClient({
baseURL: baseUrl,
...config,
});
};
11 changes: 7 additions & 4 deletions app/frontend/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ if (!process.env.API_SPEC) {
throw new Error("API_SPEC environment variable is not set");
}

if (!process.env.API_URL) {
throw new Error("API_URL environment variable is not set");
}

export default defineConfig({
api: {
input: { target: process.env.API_SPEC },
Expand All @@ -25,7 +21,14 @@ export default defineConfig({
},
},
},
...(!process.env.API_URL && {
mutator: {
path: "./lib/dev-axios-config.ts",
name: "myAxios",
},
}),
},
...(process.env.API_URL && { baseUrl: process.env.API_URL }),
},
},
});
6 changes: 3 additions & 3 deletions app/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"dev": "bun run scripts/dev.ts",
"build": "bun run scripts/build.ts",
"preview": "vike preview",
"postinstall": "bun run scripts/postinstall.ts",
"lint": "eslint ."
"lint": "eslint .",
"setup": "bun run scripts/setup.ts"
},
"dependencies": {
"@heroicons/react": "^2.2.0",
"@tanstack/react-query": "^5.85.5",
"@vitejs/plugin-react": "^4.7.0",
"axios": "^1.11.0",
"axios": "^1.13.6",
"leaflet": "^1.9.4",
"react": "^19.1.0",
"react-dom": "^19.1.0",
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
dockerfile: Dockerfile.frontend
environment:
- API_SPEC=./openapi-spec/openapi.yaml
- API_URL=http://backend:8080
- NODE_ENV=production
depends_on:
backend:
Expand Down Expand Up @@ -41,19 +40,19 @@ services:
db_init:
condition: service_completed_successfully
environment:
- API_SPEC=./openapi-spec/openapi.yaml
- TABLE_NAME=LocalDevTable
- AWS_ACCESS_KEY_ID=local
- AWS_SECRET_ACCESS_KEY=local
- AWS_REGION=us-west-2
- DYNAMODB_ENDPOINT=http://localstack:4566
- IMAGE_BUCKET_NAME=my-bucket
- COGNITO_USER_POOL_ID=us-west-2_XXXXXXXXX
- COGNITO_CLIENT_ID=XXXXXXXXXXXXXXXX
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/ping"]
interval: 5s
timeout: 2s
retries: 5
start_period: 150s
localstack:
image: localstack/localstack:stable
ports:
Expand Down