Skip to content

Commit 652e0b2

Browse files
committed
fix[docker]: fixed devcontainer to match new file structure
1 parent 4d07eaf commit 652e0b2

File tree

9 files changed

+50
-45
lines changed

9 files changed

+50
-45
lines changed

.devcontainer/.bashrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ alias ..="cd .."
1414
alias ...="cd ../.."
1515

1616
# Database aliases
17-
alias pgc="PGPASSWORD=postgres psql -h db -U postgres -d postgres"
17+
alias pgc="PGPASSWORD=postgres psql -h db -U postgres -d simstudio"
1818
alias check-db="PGPASSWORD=postgres psql -h db -U postgres -c '\l'"
1919

2020
# Sim Studio specific aliases

.devcontainer/Dockerfile

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ FROM node:20-bullseye
33
# Avoid warnings by switching to noninteractive
44
ENV DEBIAN_FRONTEND=noninteractive
55

6-
# Configure apt and install packages
6+
# Install necessary packages for development
77
RUN apt-get update \
8-
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
9-
# Install git, process tools, lsb-release
10-
&& apt-get -y install git procps lsb-release \
11-
# Install other dependencies
12-
&& apt-get -y install curl wget jq sudo \
13-
# Clean up
14-
&& apt-get autoremove -y \
8+
&& apt-get -y install --no-install-recommends \
9+
git curl wget jq sudo postgresql-client \
1510
&& apt-get clean -y \
1611
&& rm -rf /var/lib/apt/lists/*
1712

@@ -20,10 +15,8 @@ ARG USERNAME=node
2015
ARG USER_UID=1000
2116
ARG USER_GID=$USER_UID
2217

23-
# [Optional] Add sudo support
24-
RUN apt-get update \
25-
&& apt-get install -y sudo \
26-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
18+
# Add sudo support
19+
RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \
2720
&& chmod 0440 /etc/sudoers.d/$USERNAME
2821

2922
# Make sure we have the latest npm
@@ -32,15 +25,10 @@ RUN npm install -g npm@latest
3225
# Install global packages
3326
RUN npm install -g drizzle-kit
3427

35-
# Install dependencies for Postgres client
36-
RUN apt-get update && apt-get -y install --no-install-recommends \
37-
postgresql-client \
38-
&& rm -rf /var/lib/apt/lists/*
39-
4028
# Switch back to dialog for any ad-hoc use of apt-get
4129
ENV DEBIAN_FRONTEND=dialog
4230

4331
WORKDIR /workspace
4432

4533
# Expose the ports we're interested in
46-
EXPOSE 3000
34+
EXPOSE 3000

.devcontainer/devcontainer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252
"remoteUser": "node",
5353

5454
"features": {
55-
"ghcr.io/devcontainers/features/node:1": {
56-
"version": "20"
57-
},
5855
"ghcr.io/devcontainers/features/git:1": {},
5956
"ghcr.io/devcontainers-contrib/features/npm-package:1": {
6057
"package": "typescript",

.devcontainer/docker-compose.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,34 @@ services:
99
- ..:/workspace:cached
1010
command: sleep infinity
1111
environment:
12-
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
13-
- NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL:-http://db:5432}
14-
- NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY:-your-anon-key}
12+
- NODE_ENV=development
13+
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
14+
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
15+
- BETTER_AUTH_URL=http://localhost:3000
16+
- NEXT_PUBLIC_APP_URL=http://localhost:3000
1517
depends_on:
16-
- db
17-
network_mode: service:db
18+
db:
19+
condition: service_healthy
20+
ports:
21+
- "3000:3000"
1822
working_dir: /workspace/sim
1923

2024
db:
21-
image: postgres:14
25+
image: postgres:16
2226
restart: unless-stopped
2327
volumes:
2428
- postgres-data:/var/lib/postgresql/data
2529
environment:
26-
POSTGRES_PASSWORD: postgres
27-
POSTGRES_USER: postgres
28-
POSTGRES_DB: postgres
30+
- POSTGRES_USER=postgres
31+
- POSTGRES_PASSWORD=postgres
32+
- POSTGRES_DB=simstudio
2933
ports:
3034
- "5432:5432"
31-
- "3000:3000"
35+
healthcheck:
36+
test: ["CMD-SHELL", "pg_isready -U postgres"]
37+
interval: 5s
38+
timeout: 5s
39+
retries: 5
3240

3341
volumes:
3442
postgres-data:

.devcontainer/post-create.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,22 @@ npm install || {
2929
# Set up environment variables if .env doesn't exist
3030
if [ ! -f ".env" ]; then
3131
echo "📄 Creating .env file from template..."
32-
cp .env.example .env 2>/dev/null || echo "DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres" > .env
32+
cp .env.example .env 2>/dev/null || echo "DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio" > .env
3333
fi
3434

35-
# Run database migrations
36-
echo "🗃️ Running database migrations..."
35+
# Generate schema and run database migrations
36+
echo "🗃️ Running database schema generation and migrations..."
37+
echo "Generating schema..."
38+
npx drizzle-kit generate
39+
3740
echo "Waiting for database to be ready..."
3841
# Try to connect to the database, but don't fail the script if it doesn't work
3942
(
4043
timeout=60
4144
while [ $timeout -gt 0 ]; do
4245
if PGPASSWORD=postgres psql -h db -U postgres -c '\q' 2>/dev/null; then
4346
echo "Database is ready!"
44-
npx drizzle-kit push
47+
DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push
4548
break
4649
fi
4750
echo "Database is unavailable - sleeping (${timeout}s remaining)"
@@ -58,7 +61,7 @@ echo "Waiting for database to be ready..."
5861
cat << EOF >> ~/.bashrc
5962
6063
# Additional Sim Studio Development Aliases
61-
alias migrate="cd /workspace/sim && npx drizzle-kit push"
64+
alias migrate="cd /workspace/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push"
6265
alias generate="cd /workspace/sim && npx drizzle-kit generate"
6366
alias dev="cd /workspace/sim && npm run dev"
6467
alias build="cd /workspace/sim && npm run build"

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ COPY sim/ ./
99
# Install dependencies
1010
RUN npm install
1111

12+
# Generate database schema
13+
RUN npx drizzle-kit generate
14+
1215
EXPOSE 3000
1316

17+
# Create a startup script that will run migrations and then start the app
18+
RUN echo '#!/bin/sh\nnpx drizzle-kit push\nexec "$@"' > /app/docker-entrypoint.sh && \
19+
chmod +x /app/docker-entrypoint.sh
20+
21+
ENTRYPOINT ["/app/docker-entrypoint.sh"]
22+
1423
# Default to development mode
1524
CMD ["npm", "run", "dev"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ There are several ways to self-host Sim Studio:
3636
git clone https://github.com/YOUR_USERNAME/sim.git
3737
cd sim
3838

39-
# Create environment file
39+
# Create environment file and update with required environment variables (BETTER_AUTH_SECRET)
4040
cp sim/.env.example sim/.env
4141

4242
# Start the Docker environment
@@ -140,4 +140,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
140140

141141
##
142142

143-
<p align="center">Made with ❤️ by the Sim Studio Team</p>
143+
<p align="center">Made with ❤️ by the Sim Studio Team</p>

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ services:
1818
- BETTER_AUTH_URL=http://localhost:3000
1919
- NEXT_PUBLIC_APP_URL=http://localhost:3000
2020
depends_on:
21-
- db
22-
command: npm run dev
21+
db:
22+
condition: service_healthy
2323

2424
db:
25-
image: postgres:16-alpine
25+
image: postgres:16
2626
restart: always
2727
ports:
2828
- "5432:5432"

sim/.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres"
55
BETTER_AUTH_SECRET=your_secret_key # Use `openssl rand -hex 32` to generate, or visit https://www.better-auth.com/docs/installation
66
BETTER_AUTH_URL=http://localhost:3000
77

8+
## Security (Required)
9+
ENCRYPTION_KEY=your_encryption_key # Use `openssl rand -hex 64` to generate
10+
811
# Email Provider (Optional)
912
# RESEND_API_KEY= # Uncomment and add your key from https://resend.com to send actual emails
1013
# If left commented out, emails will be logged to console instead
1114

12-
# App URL (Required)
13-
NEXT_PUBLIC_APP_URL=http://localhost:3000
14-
1515
# StackBlitz (Webcontainer) API Key (Optional, for handling sandboxed code execution for functions/custom-tools)
1616
# WEBCONTAINER_CLIENT_ID= # Uncomment and add your key from https://stackblitz.com/docs/webcontainer-api#webcontainer-client-id

0 commit comments

Comments
 (0)