mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-12 00:07:40 +01:00
MISC: Dockerized Bitburner (#1891)
This commit is contained in:
parent
0d555f9347
commit
7fa85a926a
@ -1,14 +1,12 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
.git
|
test/
|
||||||
.gitattributes
|
dist/
|
||||||
.gitignore
|
.app/
|
||||||
|
|
||||||
|
.github
|
||||||
.editorconfig
|
.editorconfig
|
||||||
|
|
||||||
.dockerignore
|
.dockerignore
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
|
||||||
*.md
|
|
||||||
Quotes.txt
|
|
||||||
netscript_tests/
|
|
||||||
|
50
Dockerfile
Normal file
50
Dockerfile
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Stage 1: Build the application
|
||||||
|
FROM node:lts-alpine AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install necessary tools, including git
|
||||||
|
RUN apk update && \
|
||||||
|
apk add --no-cache git && \
|
||||||
|
apk add bash
|
||||||
|
|
||||||
|
# Copy dependencies
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
COPY tools/ ./tools
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the application
|
||||||
|
# Pass the build mode as a build argument
|
||||||
|
ARG BUILD_MODE
|
||||||
|
# Use shell logic to determine which version to install
|
||||||
|
RUN if [ "$BUILD_MODE" = "dev" ]; then \
|
||||||
|
echo "Installing development version"; \
|
||||||
|
npm run build:dev; \
|
||||||
|
else \
|
||||||
|
echo "Installing production version"; \
|
||||||
|
npm run build; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stage 2: Serve the application using Nginx
|
||||||
|
FROM nginx:stable-alpine AS runtime
|
||||||
|
|
||||||
|
# Security optimizations
|
||||||
|
RUN chmod -R 644 /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Copy the built application from the builder stage
|
||||||
|
COPY --from=builder /app/.app /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Set permissions for security
|
||||||
|
RUN chmod -R 755 /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start Nginx
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
bitburner-app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
BUILD_MODE: production # Pass the build mode to the Dockerfile
|
||||||
|
ports:
|
||||||
|
- "8080:80" # Map port 8080 on the host to port 80 in the container
|
||||||
|
restart: unless-stopped
|
Loading…
Reference in New Issue
Block a user