Skip to content

Commit

Permalink
fixed docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
Raj Nandan Sharma authored and Raj Nandan Sharma committed Nov 13, 2024
1 parent c57f75d commit c992ec2
Show file tree
Hide file tree
Showing 26 changed files with 178 additions and 2,806 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config/static/*
!config/static/.kener
db/*
!db/.kener
src/lib/server/data/*
!src/lib/server/data/.kener
database/*
!database/.kener
src/lib/server/config/monitors.yaml
src/lib/server/config/site.yaml
75 changes: 40 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
# Stage 1: Base image
FROM lsiobase/alpine:3.18 AS build
# Stage 1: Build stage
FROM node:18-alpine AS builder

WORKDIR /app

# Copy package files first for better caching
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy project files
COPY . .

# Build the application
RUN npm run build

# Stage 2: Run stage
FROM lsiobase/alpine:3.18

# Set timezone and user
ENV TZ=Etc/GMT
ENV PUID=911
ENV PGID=911
ENV TZ=Etc/GMT \
PUID=911 \
PGID=911 \
NODE_ENV=production \
PORT=3000

# Install Node.js and npm
RUN echo "**** install build packages ****" && \
Expand All @@ -20,48 +39,34 @@ RUN echo "**** install build packages ****" && \
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone

# Set working directory
WORKDIR /app

# Copy built files from builder stage
COPY --from=builder /app/build ./build
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/main.js ./
COPY --from=builder /app/build.js ./
COPY --from=builder /app/src ./src
COPY --from=builder /app/static ./static
COPY --from=builder /app/database ./database
COPY --from=builder /app/config ./config
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.env ./.env

# Install production dependencies only

# Copy package files first for better caching
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy project files
COPY . .

# Create database directory

# Create and configure database directory
RUN mkdir -p /app/database && \
chown -R $PUID:$PGID /app/database && \
chmod -R 755 /app/database

# Set production environment
ENV NODE_ENV=production \
PORT=3000 \
TZ=Etc/GMT \
PUID=911 \
PGID=911
# Copy database contents if they exist
# Declare volume for persistence
VOLUME /app/database


# Build application
RUN node build.js && \
npm run build

RUN npm install -g vite-node

# Use PORT env variable
# Expose port
EXPOSE $PORT

# Print PORT env variable
RUN echo "PORT: $PORT"

# Set startup command

CMD ["sh", "-c", "vite-node src/lib/server/startup.js & node main.js & wait"]
CMD ["sh", "-c", "node build.js && (node src/lib/server/startup.js & node main.js & wait)"]
1 change: 1 addition & 0 deletions database/.kener
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
database folder
Loading

0 comments on commit c992ec2

Please sign in to comment.