From 5a27070437ad36bd44327ff1badc5958da6fd237 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Fri, 6 Dec 2024 18:08:27 +0500 Subject: [PATCH] undockerize --- .dockerignore | 36 -------------------- .gitignore | 2 +- Dockerfile | 83 ----------------------------------------------- compose.yaml | 17 ---------- config.example.js | 18 ++++++++++ package.json | 1 - pnpm-lock.yaml | 9 ----- stack.env.example | 8 ----- 8 files changed, 19 insertions(+), 155 deletions(-) delete mode 100644 .dockerignore delete mode 100644 Dockerfile delete mode 100644 compose.yaml create mode 100644 config.example.js delete mode 100644 stack.env.example diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2af4c5e..0000000 --- a/.dockerignore +++ /dev/null @@ -1,36 +0,0 @@ -# For more help, visit the .dockerignore file reference guide [here](https://docs.docker.com/go/build-context-dockerignore/) - -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/.next -**/.cache -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/charts -**/docker-compose* -**/compose.y*ml -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -**/build -**/dist -LICENSE -README.md - -data/main_db.json -data/test_db.json -stack.env -public/css/*.css -public/courses/*.txt diff --git a/.gitignore b/.gitignore index 9cabe0c..7916622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # Custom -stack.env public/css/* public/courses/* data/* !data/main_db.example.json +config.js # Logs logs diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5a20af3..0000000 --- a/Dockerfile +++ /dev/null @@ -1,83 +0,0 @@ -# syntax=docker/dockerfile:1 - -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/go/dockerfile-reference/ - -# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 - -ARG NODE_VERSION=18.17.1 -ARG PNPM_VERSION=9.7.1 - -################################################################################ -# Use node image for base image for all stages. -FROM node:${NODE_VERSION}-alpine as base - -# Set working directory for all build stages. -WORKDIR /usr/src/app - -# Install pnpm. -RUN --mount=type=cache,target=/root/.npm \ - npm install -g pnpm@${PNPM_VERSION} - -################################################################################ -# Create a stage for installing production dependecies. -FROM base as deps - -# Download dependencies as a separate step to take advantage of Docker's caching. -# Leverage a cache mount to /root/.local/share/pnpm/store to speed up subsequent builds. -# Leverage bind mounts to package.json and pnpm-lock.yaml to avoid having to copy them -# into this layer. -RUN --mount=type=bind,source=package.json,target=package.json \ - --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ - --mount=type=cache,target=/root/.local/share/pnpm/store \ - pnpm install --prod --frozen-lockfile - -################################################################################ -# Create a stage for building the application. -FROM deps as build - -# Download additional development dependencies before building, as some projects require -# "devDependencies" to be installed to build. If you don't need this, remove this step. -RUN --mount=type=bind,source=package.json,target=package.json \ - --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ - --mount=type=cache,target=/root/.local/share/pnpm/store \ - pnpm install --frozen-lockfile - -# Copy the rest of the source files into the image. -COPY . . - -# Run the build script. -RUN pnpm run build - -# This project specific -RUN mv stack.env.example stack.env -RUN mv data/main_db.example.json data/main_db.json -RUN chmod -R 777 data/ -RUN chmod -R 777 public/ -# End - -################################################################################ -# Create a new stage to run the application with minimal runtime dependencies -# where the necessary files are copied from the build stage. -FROM base as final - -# Use production node environment by default. -ENV NODE_ENV production - -# Run the application as a non-root user. -USER node - -# Copy package.json so that package manager commands can be used. -COPY package.json . - -# Copy the production dependencies from the deps stage and also -# the built application from the build stage into the image. -COPY --from=deps /usr/src/app/node_modules ./node_modules -COPY --from=build /usr/src/app/. ./. - -# Expose the port that the application listens on. -EXPOSE 6547 - -# Run the application. -CMD pnpm start diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 4c476ab..0000000 --- a/compose.yaml +++ /dev/null @@ -1,17 +0,0 @@ -services: - server: - user: root - build: - context: . - env_file: - - stack.env - volumes: - - courses:/usr/src/app/public/courses - - data:/usr/src/app/data - ports: - - 6547:6547 - restart: unless-stopped - -volumes: - courses: - data: \ No newline at end of file diff --git a/config.example.js b/config.example.js new file mode 100644 index 0000000..3c6f642 --- /dev/null +++ b/config.example.js @@ -0,0 +1,18 @@ +module.exports = { + /* Set true for production database */ + production: true, + /* Your domain without / at the end */ + domain: "http://localhost:6547", + /* Port for the server */ + port: 6547, + /* How often can user send request to API */ + rateLimitTime: 1000 * 5, // 5 seconds + /* How often can user change IP address */ + ipChangeTime: 1000 * 60 * 60 * 3, // 3 hours + /* Your SteamAPI key */ + steamKey: "", + /* Secret for a cookie */ + cookieSecret: "", + /* Discord webhook url or leave empty */ + webhook_url: "", +}; diff --git a/package.json b/package.json index d87a526..6e727c7 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "dependencies": { "daisyui": "^4.11.1", - "dotenv": "^16.4.5", "ejs": "^2.6.1", "express": "^4.16.1", "express-session": "^1.18.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1be0dbf..959da94 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: daisyui: specifier: ^4.11.1 version: 4.11.1(postcss@8.4.36) - dotenv: - specifier: ^16.4.5 - version: 16.4.5 ejs: specifier: ^2.6.1 version: 2.6.2 @@ -398,10 +395,6 @@ packages: domutils@3.1.0: resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==} - dotenv@16.4.5: - resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} - engines: {node: '>=12'} - eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -1586,8 +1579,6 @@ snapshots: domelementtype: 2.3.0 domhandler: 5.0.3 - dotenv@16.4.5: {} - eastasianwidth@0.2.0: {} ee-first@1.1.1: {} diff --git a/stack.env.example b/stack.env.example deleted file mode 100644 index ab9dc98..0000000 --- a/stack.env.example +++ /dev/null @@ -1,8 +0,0 @@ -PROD=true -DOMAIN=http://localhost:6547 -PORT=6547 -RATELIMIT=5000 -IPCHANGETIME=10800000 -STEAMKEY=NO_KEY -COOKIE=NO_COOKIE -WEBHOOK="" \ No newline at end of file