diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3937fe6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +.DS_Store +node_modules +/dist + +.gitignore +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.gitignore b/.gitignore index 403adbc..6ca8164 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,6 @@ -.DS_Store -node_modules -/dist - - -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files +.git +.gitignore .idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? +**/node_modules +.DS_Store +.data \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b02dd90 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM node:14 + +ENV baseURL "http://localhost:3000/api/v1/" +ENV RCON_HOST "" +ENV RCON_PASSWORD "" +ENV RCON_PORT 21114 +ENV JWT_SECRET "" +ENV DB_HOST "" +ENV DB_USER "" +ENV DB_PASS "" +ENV DB_BASE "" +ENV DB_DIAL "" +ENV DB_PORT "" + +EXPOSE 3000 + +RUN yarn global add @vue/cli +WORKDIR /usr/src/sqcp +COPY backend ./backend +COPY frontend/squad-control-panel ./frontend +COPY entrypoint.sh ./entrypoint.sh + +WORKDIR /usr/src/sqcp/frontend +RUN yarn install +RUN yarn build +RUN cp -R ./dist ../backend/ + +WORKDIR /usr/src/sqcp/backend +RUN yarn install + +ENTRYPOINT ["/bin/bash", "/usr/src/sqcp/entrypoint.sh"] +CMD [ "yarn", "start" ] \ No newline at end of file diff --git a/backend/Config/index.js b/backend/Config/index.js index 97e0b18..7f285a2 100644 --- a/backend/Config/index.js +++ b/backend/Config/index.js @@ -12,12 +12,12 @@ const Config = { }, DATABASE: { - host: Database[MODE].host, - user: Database[MODE].username, - password: Database[MODE].password, - database: Database[MODE].database, - dialect: Database[MODE].dialect, - port: Database[MODE].port, + host: process.env.DB_HOST, + user: process.env.DB_USER, + password: process.env.DB_PASS, + database: process.env.DB_BASE, + dialect: process.env.DB_DIAL, + port: process.env.DB_PORT, }, LOGGER_MODULES: { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7fe010d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.1' + +volumes: + sqcp_data: + db_data: +services: + sqcp: + image: immervoll/sqcp + restart: always + volumes: + - sqcp_data:/usr/src/sqcp/backend/Config/ + ports: + - 3000:3000 + links: + - "db" + environment: + RCON_HOST: "ip" + RCON_PASSWORD: "pw" + RCON_PORT: "21114" + JWT_SECRET: "" + DB_HOST: db + DB_USER: "sqcp" + DB_PASS: "securepw" + DB_BASE: "sqcp" + DB_DIAL: "mysql" + DB_PORT: "3306" + + db: + image: mysql + restart: always + volumes: + - db_data:/var/lib/mysql/ + environment: + MYSQL_ROOT_PASSWORD: "rootpass" + MYSQL_DATABASE: "sqcp" + MYSQL_USER: "sqcp" + MYSQL_PASSWORD: "securepw" + + + \ No newline at end of file diff --git a/docs/setup.md b/docs/setup.md index a294714..bdb67cd 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -86,3 +86,52 @@ _PS: I expect you have a technical background and you already are familiar with 21. Restart the server Congratulations, you are done! + +## **Setup via Docker** +1. Create a docker-compose.yml +
Example: + ```yaml + version: '3.1' + + volumes: + sqcp_data: + db_data: + services: + sqcp: + image: immervoll/sqcp + restart: always + volumes: + - sqcp_data:/usr/src/sqcp/backend/Config/ + ports: + - 3000:3000 + links: + - "db" + environment: + RCON_HOST: "ip" + RCON_PASSWORD: "pw" + RCON_PORT: "21114" + JWT_SECRET: "" + DB_HOST: db + DB_USER: "sqcp" + DB_PASS: "securepw" + DB_BASE: "sqcp" + DB_DIAL: "mysql" + DB_PORT: "3306" + + db: + image: mysql + restart: always + volumes: + - db_data:/var/lib/mysql/ + environment: + MYSQL_ROOT_PASSWORD: "rootpass" + MYSQL_DATABASE: "sqcp" + MYSQL_USER: "sqcp" + MYSQL_PASSWORD: "securepw" + ``` +1. docker-compose up +2. navigate to `/usr/src/sqcp/backend/Config` and add the Database information to `database.json` +3. restart the sqcp container + +Congratulations, you are done! + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b6ed15b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#entrypoint.sh + +cd /usr/src/sqcp/backend +npx sequelize db:migrate --config Config/database.json +npm run create-admin +yarn start \ No newline at end of file diff --git a/frontend/squad-control-panel/src/main.js b/frontend/squad-control-panel/src/main.js index 8a18653..211df52 100644 --- a/frontend/squad-control-panel/src/main.js +++ b/frontend/squad-control-panel/src/main.js @@ -14,7 +14,7 @@ import 'sweetalert2/dist/sweetalert2.min.css'; // Config Vue.config.productionTip = false; -Vue.config.baseURL = 'http://localhost/api/v1'; // Example: http://squad-control-panel.com/api/v1'; +Vue.config.baseURL = process.env.baseURL || "http://127.0.0.1:3000/api/v1"; // Example: http://squad-control-panel.com/api/v1'; // Plugins Vue.use(VueAxios, axios);