devmode
This commit is contained in:
parent
0535cd1aad
commit
ebd50740f0
6 changed files with 249 additions and 17 deletions
63
Dockerfile.dev
Normal file
63
Dockerfile.dev
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Development Dockerfile with hot reload support
|
||||
FROM golang:1.24-alpine
|
||||
|
||||
# Install development dependencies
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
musl-dev \
|
||||
nodejs \
|
||||
npm \
|
||||
sqlite \
|
||||
# For file watching
|
||||
inotify-tools
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install Air for Go hot reloading
|
||||
RUN go install github.com/cosmtrek/air@latest
|
||||
|
||||
# Copy go mod files first for better caching
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download Go dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy Air configuration
|
||||
COPY .air.toml ./
|
||||
|
||||
# Copy the entire project
|
||||
COPY . .
|
||||
|
||||
# Install frontend dependencies
|
||||
WORKDIR /app/frontend
|
||||
RUN npm install
|
||||
|
||||
# Go back to app root
|
||||
WORKDIR /app
|
||||
|
||||
# Expose ports for both backend and frontend
|
||||
EXPOSE 8080 5173
|
||||
|
||||
# Create a development startup script
|
||||
RUN echo '#!/bin/sh\n\
|
||||
echo "🚀 Starting development environment..."\n\
|
||||
echo "📡 Backend will be available at http://localhost:8080"\n\
|
||||
echo "🎨 Frontend will be available at http://localhost:5173"\n\
|
||||
echo ""\n\
|
||||
# Start frontend in background\n\
|
||||
cd /app/frontend && npm run dev &\n\
|
||||
FRONTEND_PID=$!\n\
|
||||
\n\
|
||||
# Start backend with Air\n\
|
||||
cd /app && air\n\
|
||||
\n\
|
||||
# Cleanup on exit\n\
|
||||
trap "kill $FRONTEND_PID" EXIT\n\
|
||||
wait\n\
|
||||
' > /app/dev-start.sh && chmod +x /app/dev-start.sh
|
||||
|
||||
# Set the development startup script as entrypoint
|
||||
ENTRYPOINT ["/app/dev-start.sh"]
|
Loading…
Add table
Add a link
Reference in a new issue