mirror of
https://github.com/philipredstone/relnet.git
synced 2025-06-16 20:51:16 +02:00
Merge branch 'main' of https://github.com/philipredstone/relnet
This commit is contained in:
commit
11b83eeffc
62
Dockerfile
62
Dockerfile
@ -1,47 +1,63 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
FROM node:22 AS frontend-builder
|
|
||||||
|
|
||||||
# Workingdir
|
# Frontend builder stage
|
||||||
|
FROM oven/bun:1 AS frontend-builder
|
||||||
WORKDIR /frontend
|
WORKDIR /frontend
|
||||||
|
|
||||||
# Copy files
|
# Install dependencies
|
||||||
|
COPY frontend/package.json frontend/bun.lockb* ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source files
|
||||||
COPY frontend/src/ src/
|
COPY frontend/src/ src/
|
||||||
COPY frontend/package.json .
|
|
||||||
COPY frontend/index.html .
|
COPY frontend/index.html .
|
||||||
COPY frontend/tsconfig.json .
|
COPY frontend/tsconfig.json .
|
||||||
COPY frontend/vite.config.mjs .
|
COPY frontend/vite.config.mjs .
|
||||||
|
|
||||||
# Install libs
|
# Build the frontend
|
||||||
RUN yarn install
|
RUN bun run build
|
||||||
# Build to dist/
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
|
# Backend builder stage
|
||||||
FROM node:22 AS backend-builder
|
FROM oven/bun:1 AS backend-builder
|
||||||
|
|
||||||
# Workingdir
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json .
|
# Copy package files first for better caching
|
||||||
RUN yarn install
|
COPY package.json bun.lockb* ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source files
|
||||||
COPY tsconfig.json .
|
COPY tsconfig.json .
|
||||||
COPY src/ src/
|
COPY src/ src/
|
||||||
|
|
||||||
# Build to dist/
|
# Build the backend
|
||||||
RUN yarn run build
|
RUN bun run build
|
||||||
|
|
||||||
|
# Final production stage
|
||||||
|
FROM oven/bun:1-slim
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
# Final stage
|
# Copy built artifacts from previous stages
|
||||||
FROM node:22-slim
|
COPY --from=frontend-builder /frontend/dist/ ./frontend/dist
|
||||||
COPY --from=frontend-builder /frontend/dist/ frontend/dist
|
COPY --from=backend-builder /app/dist/ ./dist/
|
||||||
COPY --from=backend-builder /app/dist/ dist/
|
|
||||||
COPY --from=backend-builder /app/node_modules node_modules
|
|
||||||
COPY package.json .
|
|
||||||
|
|
||||||
|
# Only copy production dependencies
|
||||||
|
COPY package.json ./
|
||||||
|
RUN bun install --production --frozen-lockfile
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
ENV PORT=80
|
ENV PORT=80
|
||||||
ENV MONGODB_URI=mongodb://db:27017/friendship-network
|
ENV MONGODB_URI=mongodb://db:27017/friendship-network
|
||||||
ENV APP_URL=http://localhost:80
|
ENV APP_URL=http://localhost:80
|
||||||
ENV ENABLE_REGISTRATION=true
|
ENV ENABLE_REGISTRATION=true
|
||||||
|
|
||||||
CMD ["yarn", "run", "start"]
|
# Expose the port
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Health check to verify the application is running
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:$PORT/api/health || exit 1
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
CMD ["bun", "run", "start"]
|
@ -51,6 +51,11 @@ app.use('/api/networks', networkRoutes);
|
|||||||
app.use('/api/networks', peopleRoutes);
|
app.use('/api/networks', peopleRoutes);
|
||||||
app.use('/api/networks', relationshipRoutes);
|
app.use('/api/networks', relationshipRoutes);
|
||||||
|
|
||||||
|
// Health check
|
||||||
|
app.get('/api/health', (req, res) => {
|
||||||
|
res.send('OK');
|
||||||
|
});
|
||||||
|
|
||||||
app.use(express.static(path.join(__dirname, '../frontend/dist/')));
|
app.use(express.static(path.join(__dirname, '../frontend/dist/')));
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user