mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 07:23:58 +00:00
docker build
This commit is contained in:
32
.github/workflows/build-app.yaml
vendored
32
.github/workflows/build-app.yaml
vendored
@@ -1,11 +1,11 @@
|
|||||||
name: Docker image
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
# on:
|
name: Electron app
|
||||||
# push:
|
|
||||||
# branches:
|
on:
|
||||||
# - production
|
push:
|
||||||
|
branches:
|
||||||
|
- production
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -32,9 +32,21 @@ jobs:
|
|||||||
- name: yarn install
|
- name: yarn install
|
||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
- name: Prepare docker image
|
- name: Publish
|
||||||
run: |
|
run: |
|
||||||
yarn run prepare:docker
|
yarn run build:app
|
||||||
- name: Build docker image
|
- name: Cleanup artifacts
|
||||||
run: |
|
run: |
|
||||||
docker build ./docker
|
npx rimraf "app/dist/!(*.exe|*.deb|*.AppImage|*.dmg)"
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.os }}
|
||||||
|
path: app/dist
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: "app/dist/**"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
37
.github/workflows/build-docker.yaml
vendored
37
.github/workflows/build-docker.yaml
vendored
@@ -1,9 +1,11 @@
|
|||||||
name: Electron app
|
name: Docker image
|
||||||
|
|
||||||
on:
|
on: [push]
|
||||||
push:
|
|
||||||
branches:
|
# on:
|
||||||
- production
|
# push:
|
||||||
|
# branches:
|
||||||
|
# - production
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -30,21 +32,14 @@ jobs:
|
|||||||
- name: yarn install
|
- name: yarn install
|
||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
- name: Publish
|
- name: Prepare docker image
|
||||||
run: |
|
run: |
|
||||||
yarn run build:app
|
yarn run prepare:docker
|
||||||
- name: Cleanup artifacts
|
- name: Build docker image
|
||||||
run: |
|
run: |
|
||||||
npx rimraf "app/dist/!(*.exe|*.deb|*.AppImage|*.dmg)"
|
docker build ./docker -t dbgate:future
|
||||||
- name: Upload artifacts
|
- name: Push docker image
|
||||||
uses: actions/upload-artifact@v1
|
run: |
|
||||||
with:
|
docker tag dbgate:future dbgate/dbgate:future
|
||||||
name: ${{ matrix.os }}
|
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||||
path: app/dist
|
docker push dbgate/dbgate:future
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
files: "app/dist/**"
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
# base image
|
FROM node:12-alpine
|
||||||
FROM node:10
|
|
||||||
|
|
||||||
# set working directory
|
WORKDIR /home/dbgate-docker
|
||||||
WORKDIR /home/jenasoft/dbgate
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN yarn
|
WORKDIR /home/dbgate-docker
|
||||||
RUN yarn build:api
|
EXPOSE 3000
|
||||||
RUN yarn build:web
|
CMD node bundle.js
|
||||||
|
|
||||||
# start app
|
|
||||||
WORKDIR /home/jenasoft/raftcz-frontend/build
|
|
||||||
EXPOSE 5000
|
|
||||||
# CMD yarn start
|
|
||||||
CMD serve -s
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module.exports = {
|
|||||||
opened: [],
|
opened: [],
|
||||||
|
|
||||||
async _init() {
|
async _init() {
|
||||||
const dir = await datadir();
|
const dir = datadir();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.datastore = nedb.create(path.join(dir, 'connections.jsonl'));
|
this.datastore = nedb.create(path.join(dir, 'connections.jsonl'));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ function start() {
|
|||||||
useController(app, '/database-connections', databaseConnections);
|
useController(app, '/database-connections', databaseConnections);
|
||||||
useController(app, '/tables', tables);
|
useController(app, '/tables', tables);
|
||||||
|
|
||||||
if (fs.existsSync(`${__dirname}/build`)) {
|
if (fs.existsSync('/home/dbgate-docker/build')) {
|
||||||
app.use(express.static(`${__dirname}/build`));
|
// server static files inside docker container
|
||||||
|
app.use(express.static('/home/dbgate-docker/build'));
|
||||||
} else {
|
} else {
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.send('DbGate API');
|
res.send('DbGate API');
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs');
|
||||||
|
|
||||||
let created = false;
|
let created = false;
|
||||||
|
|
||||||
module.exports = async function datadir() {
|
module.exports = function datadir() {
|
||||||
const dir = path.join(os.homedir(), 'dbgate-data');
|
const dir = path.join(os.homedir(), 'dbgate-data');
|
||||||
if (!created) {
|
if (!created) {
|
||||||
const stat = await fs.stat(dir);
|
if (!fs.existsSync(dir)) {
|
||||||
if (!stat.isDirectory) {
|
console.log(`Creating data directory ${dir}`)
|
||||||
await fs.mkdir(dir);
|
fs.mkdirSync(dir);
|
||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,16 @@ const express = require('express');
|
|||||||
module.exports = function useController(app, route, controller) {
|
module.exports = function useController(app, route, controller) {
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
if (controller._init) {
|
||||||
|
console.log(`Calling init controller for controller ${route}`);
|
||||||
|
try {
|
||||||
|
controller._init();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`Error initializing controller, exiting application`, err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const key of _.keys(controller)) {
|
for (const key of _.keys(controller)) {
|
||||||
const obj = controller[key];
|
const obj = controller[key];
|
||||||
if (!_.isFunction(obj)) continue;
|
if (!_.isFunction(obj)) continue;
|
||||||
@@ -31,10 +41,10 @@ module.exports = function useController(app, route, controller) {
|
|||||||
router[method](route, controller[key]);
|
router[method](route, controller[key]);
|
||||||
} else {
|
} else {
|
||||||
router[method](route, async (req, res) => {
|
router[method](route, async (req, res) => {
|
||||||
if (controller._init && !controller._init_called) {
|
// if (controller._init && !controller._init_called) {
|
||||||
await controller._init();
|
// await controller._init();
|
||||||
controller._init_called = true;
|
// controller._init_called = true;
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
let params = [{ ...req.body, ...req.query }];
|
let params = [{ ...req.body, ...req.query }];
|
||||||
if (rawParams) params = [req, res];
|
if (rawParams) params = [req, res];
|
||||||
|
|||||||
Reference in New Issue
Block a user