example services contains a default nginx server for simplicity

This commit is contained in:
geoffsee
2025-09-01 10:23:16 -04:00
parent 294a310eee
commit fa754accdd
10 changed files with 2 additions and 170 deletions

View File

@@ -1,38 +0,0 @@
FROM rust:1-slim-bookworm as build
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
build-essential \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Add wasm32 target for Cloudflare Workers
RUN rustup target add wasm32-unknown-unknown
# Copy project files
COPY Cargo.toml Cargo.lock ./
COPY wrangler.jsonc ./
COPY src/ ./src/
# Install worker-build and build the project
RUN cargo install -q worker-build && worker-build --release
FROM node:20-slim
WORKDIR /app
# Install wrangler
RUN npm install -g wrangler
# Copy built files from build stage
COPY --from=build /app/build ./build
COPY --from=build /app/wrangler.jsonc ./
EXPOSE 8787
HEALTHCHECK CMD curl --fail http://localhost:8787 || exit 1
ENTRYPOINT ["wrangler", "dev"]

View File

@@ -1,3 +0,0 @@
/node_modules
/dist
/.wrangler

View File

@@ -1,13 +0,0 @@
FROM node:20-slim
WORKDIR /app
COPY deploy/example-service .
RUN npm install --production
EXPOSE 8787
HEALTHCHECK CMD curl --fail http://localhost:8787 || exit 1
ENTRYPOINT ["npm", "run", "dev"]

View File

@@ -1 +0,0 @@
SOME_USELESS_ENV_VAR_TO_TEST_FUNCTIONALITY=completely-useless-value

View File

@@ -1,36 +0,0 @@
import {parse} from "cookie";
export default {
async fetch(request): Promise<Response> {
// The name of the cookie
const COOKIE_NAME = "session";
const cookie = parse(request.headers.get("Cookie") || "");
if (cookie[COOKIE_NAME] != null) {
// Respond with the cookie value
return new Response(`
<html>
<body>
<h1>Cookie Status</h1>
<p>Cookie '${COOKIE_NAME}' exists with value: ${cookie[COOKIE_NAME]}</p>
</body>
</html>
`, {
headers: {
"Content-Type": "text/html"
}
});
}
return new Response(`
<html>
<body>
<h1>Cookie Status</h1>
<p>No cookie found <w></w>ith name: ${COOKIE_NAME}</p>
</body>
</html>
`, {
headers: {
"Content-Type": "text/html"
}
});
},
} satisfies ExportedHandler;

View File

@@ -1,15 +0,0 @@
{
"name": "example-service",
"type": "module",
"scripts": {
"dev": "wrangler dev",
"build": "wrangler build",
"deploy": "wrangler deploy"
},
"dependencies": {
"wrangler": "latest"
},
"devDependencies": {
"cookie": "^1.0.2"
}
}

View File

@@ -1,18 +0,0 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": [
"ESNext",
],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
}
}

View File

@@ -1,8 +0,0 @@
{
"compatibility_date": "2025-08-07",
"main": "main.ts",
"name": "example-service",
"dev": {
"ip": "0.0.0.0"
}
}

View File

@@ -1,38 +0,0 @@
FROM rust:1-slim-bookworm as build
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
build-essential \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Add wasm32 target for Cloudflare Workers
RUN rustup target add wasm32-unknown-unknown
# Copy project files
COPY Cargo.toml Cargo.lock ./
COPY wrangler.jsonc ./
COPY src/ ./src/
# Install worker-build and build the project
RUN cargo install -q worker-build && worker-build --release
FROM node:20-slim
WORKDIR /app
# Install wrangler
RUN npm install -g wrangler
# Copy built files from build stage
COPY --from=build /app/build ./build
COPY --from=build /app/wrangler.jsonc ./
EXPOSE 8787
HEALTHCHECK CMD curl --fail http://localhost:8787 || exit 1
ENTRYPOINT ["wrangler", "dev"]

View File

@@ -0,0 +1,2 @@
FROM nginx:latest
EXPOSE 80