63 lines
No EOL
1.4 KiB
Text
63 lines
No EOL
1.4 KiB
Text
# 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"] |