Skip to content

Commit 04f7b0b

Browse files
committed
add caddy
1 parent c551fb9 commit 04f7b0b

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

Caddyfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
beginner-react-challenges.webdevcody.com {
2+
reverse_proxy wdc-tanstack-starter-kit-app:3000
3+
}

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use Node.js 20 LTS as the base image
2+
FROM node:20-alpine
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Build the application
17+
RUN npm run build
18+
19+
# Expose the port your app runs on (adjust if needed)
20+
EXPOSE 3000
21+
22+
# Start the application
23+
CMD ["npm", "start"]

docker-compose.prod.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: "3.9"
2+
services:
3+
wdc-tanstack-starter-kit-db:
4+
image: postgres:17
5+
restart: always
6+
container_name: wdc-tanstack-starter-kit-db
7+
ports:
8+
- 5432:5432
9+
environment:
10+
POSTGRES_PASSWORD: example
11+
PGDATA: /data/postgres
12+
volumes:
13+
- postgres:/data/postgres
14+
15+
wdc-tanstack-starter-kit-app:
16+
build:
17+
context: .
18+
dockerfile: Dockerfile
19+
image: wdc-tanstack-starter-kit-app
20+
env_file:
21+
- .env
22+
restart: always
23+
container_name: wdc-tanstack-starter-kit-app
24+
expose:
25+
- 3000
26+
27+
caddy:
28+
image: caddy:2
29+
restart: always
30+
container_name: wdc-tanstack-starter-kit-caddy
31+
ports:
32+
- "80:80"
33+
- "443:443"
34+
volumes:
35+
- ./Caddyfile:/etc/caddy/Caddyfile
36+
- caddy_data:/data
37+
- caddy_config:/config
38+
depends_on:
39+
- wdc-tanstack-starter-kit-app
40+
41+
volumes:
42+
postgres:
43+
caddy_data:
44+
caddy_config:

source.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ -f .env ]; then
4+
# Read each line from .env file
5+
while IFS= read -r line || [ -n "$line" ]; do
6+
# Skip empty lines and comments
7+
if [[ $line =~ ^[[:space:]]*$ ]] || [[ $line =~ ^# ]]; then
8+
continue
9+
fi
10+
11+
# Export the environment variable
12+
export "$line"
13+
done < .env
14+
echo "Environment variables loaded successfully"
15+
else
16+
echo "Error: .env file not found"
17+
exit 1
18+
fi
19+

0 commit comments

Comments
 (0)