mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 09:36:00 +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:
|
||||
# push:
|
||||
# branches:
|
||||
# - production
|
||||
name: Electron app
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- production
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -32,9 +32,21 @@ jobs:
|
||||
- name: yarn install
|
||||
run: |
|
||||
yarn install
|
||||
- name: Prepare docker image
|
||||
- name: Publish
|
||||
run: |
|
||||
yarn run prepare:docker
|
||||
- name: Build docker image
|
||||
yarn run build:app
|
||||
- name: Cleanup artifacts
|
||||
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:
|
||||
push:
|
||||
branches:
|
||||
- production
|
||||
on: [push]
|
||||
|
||||
# on:
|
||||
# push:
|
||||
# branches:
|
||||
# - production
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -30,21 +32,14 @@ jobs:
|
||||
- name: yarn install
|
||||
run: |
|
||||
yarn install
|
||||
- name: Publish
|
||||
- name: Prepare docker image
|
||||
run: |
|
||||
yarn run build:app
|
||||
- name: Cleanup artifacts
|
||||
yarn run prepare:docker
|
||||
- name: Build docker image
|
||||
run: |
|
||||
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 }}
|
||||
docker build ./docker -t dbgate:future
|
||||
- name: Push docker image
|
||||
run: |
|
||||
docker tag dbgate:future dbgate/dbgate:future
|
||||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||
docker push dbgate/dbgate:future
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
# base image
|
||||
FROM node:10
|
||||
FROM node:12-alpine
|
||||
|
||||
# set working directory
|
||||
WORKDIR /home/jenasoft/dbgate
|
||||
WORKDIR /home/dbgate-docker
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN yarn
|
||||
RUN yarn build:api
|
||||
RUN yarn build:web
|
||||
|
||||
# start app
|
||||
WORKDIR /home/jenasoft/raftcz-frontend/build
|
||||
EXPOSE 5000
|
||||
# CMD yarn start
|
||||
CMD serve -s
|
||||
WORKDIR /home/dbgate-docker
|
||||
EXPOSE 3000
|
||||
CMD node bundle.js
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = {
|
||||
opened: [],
|
||||
|
||||
async _init() {
|
||||
const dir = await datadir();
|
||||
const dir = datadir();
|
||||
// @ts-ignore
|
||||
this.datastore = nedb.create(path.join(dir, 'connections.jsonl'));
|
||||
},
|
||||
|
||||
@@ -28,8 +28,9 @@ function start() {
|
||||
useController(app, '/database-connections', databaseConnections);
|
||||
useController(app, '/tables', tables);
|
||||
|
||||
if (fs.existsSync(`${__dirname}/build`)) {
|
||||
app.use(express.static(`${__dirname}/build`));
|
||||
if (fs.existsSync('/home/dbgate-docker/build')) {
|
||||
// server static files inside docker container
|
||||
app.use(express.static('/home/dbgate-docker/build'));
|
||||
} else {
|
||||
app.get('/', (req, res) => {
|
||||
res.send('DbGate API');
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const fs = require('fs');
|
||||
|
||||
let created = false;
|
||||
|
||||
module.exports = async function datadir() {
|
||||
module.exports = function datadir() {
|
||||
const dir = path.join(os.homedir(), 'dbgate-data');
|
||||
if (!created) {
|
||||
const stat = await fs.stat(dir);
|
||||
if (!stat.isDirectory) {
|
||||
await fs.mkdir(dir);
|
||||
if (!fs.existsSync(dir)) {
|
||||
console.log(`Creating data directory ${dir}`)
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
created = true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,16 @@ const express = require('express');
|
||||
module.exports = function useController(app, route, controller) {
|
||||
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)) {
|
||||
const obj = controller[key];
|
||||
if (!_.isFunction(obj)) continue;
|
||||
@@ -31,10 +41,10 @@ module.exports = function useController(app, route, controller) {
|
||||
router[method](route, controller[key]);
|
||||
} else {
|
||||
router[method](route, async (req, res) => {
|
||||
if (controller._init && !controller._init_called) {
|
||||
await controller._init();
|
||||
controller._init_called = true;
|
||||
}
|
||||
// if (controller._init && !controller._init_called) {
|
||||
// await controller._init();
|
||||
// controller._init_called = true;
|
||||
// }
|
||||
try {
|
||||
let params = [{ ...req.body, ...req.query }];
|
||||
if (rawParams) params = [req, res];
|
||||
|
||||
Reference in New Issue
Block a user