diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e4c43bf0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM node:lts-bullseye as base + +# Create a non-root user +RUN useradd -ms /bin/bash appuser + +# Install sqlite3 +RUN apt-get update && apt-get install -y sqlite3 + +# Set working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install --production + +# Copy the application code +COPY . . + +# Create hebcal-dot-com.ini file +RUN mkdir -p /etc && touch /etc/hebcal-dot-com.ini + +# Install additional dependencies +RUN npm install @hebcal/geo-sqlite + +# Download and make databases +RUN ./node_modules/.bin/download-and-make-dbs + +# Create a directory for logs +RUN mkdir -p /var/log/hebcal/ +# Grant write permissions to the non-root user +RUN chown -R appuser:appuser /var/log/hebcal + +# Set the user +USER appuser + +# Expose the port (if applicable) +EXPOSE 8080 + +# Start the application +CMD ["node", "src/app-www.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8b230ede --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.7' + +services: + hebcal-web: + container_name: hebcal-web + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:8080" + environment: + - NODE_ENV=production + restart: unless-stopped +