Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dockerfile #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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?
27 changes: 5 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
12 changes: 6 additions & 6 deletions backend/Config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"



49 changes: 49 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
</br>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!

6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion frontend/squad-control-panel/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down