Fix docker image and pipelines (#14)

This commit is contained in:
Pavel 2021-06-17 01:01:43 +03:00 committed by GitHub
parent 5919eca242
commit a60d370424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 117 additions and 48 deletions

View File

@ -1,8 +1,9 @@
name: container
name: build dev
on:
push:
# branches:
# - master
branches-ignore:
- master
workflow_dispatch:
jobs:
@ -53,11 +54,10 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
### Set container tag to 'latest' if branch is master, and to $BRANCH_NAME otherwise
- if: ${{ env.BRANCH_NAME }} != 'master'
run: echo "CONTAINER_TAG=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
- if: ${{ env.BRANCH_NAME }} == 'master'
run: echo "CONTAINER_TAG=latest" >> $GITHUB_ENV
### Set version
- run: echo "VERSION=0.1.${{github.run_number}}" >> $GITHUB_ENV
- run: echo "CONTAINER_TAG=fluencelabs/dashboard:${{ env.VERSION }}${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
### Build and push docker image
- name: Build and push
@ -67,8 +67,6 @@ jobs:
context: .
file: ./caddy.Dockerfile
push: true
tags: fluencelabs/dashboard:${{ env.CONTAINER_TAG }}
tags: ${{ env.CONTAINER_TAG }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# docker commit --change='ENTRYPOINT ["caddy", "file-server", "--root", "/build", "--browse"]' caddy fluencelabs/fluence:demo

View File

@ -1,18 +0,0 @@
name: deploy
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Deploy dashboard@master to DigitalOcean via SSH
uses: appleboy/ssh-action@v0.1.3
with:
HOST: ${{ secrets.DASHBOARD_HOST }}
USERNAME: ${{ secrets.DASHBOARD_USERNAME }}
KEY: ${{ secrets.DASHBOARD_SSHKEY }}
script: |
docker pull fluencelabs/dashboard:latest
docker rm -f dashboard
docker run -d --name dashboard -p443:443 -p80:80 -v caddy_data:/data fluencelabs/dashboard:latest

84
.github/workflows/deploy_prod.yml vendored Normal file
View File

@ -0,0 +1,84 @@
name: build and deploy prod
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
### extract branch name
- name: Extract branch name
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch
- name: Extract branch name
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- run: npm install
- run: npm run prod
env:
CI: true
### Prepare docker & login to Dockerhub
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
### Set version
- run: echo "VERSION=0.1.${{github.run_number}}" >> $GITHUB_ENV
- run: echo "CONTAINER_TAG=fluencelabs/dashboard:latest,fluencelabs/dashboard:${{ env.VERSION }}" >> $GITHUB_ENV
### Build and push docker image
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./caddy.Dockerfile
push: true
tags: ${{ env.CONTAINER_TAG }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
### Deploy
- name: Deploy dashboard@master to DigitalOcean via SSH
uses: appleboy/ssh-action@v0.1.3
with:
HOST: ${{ secrets.DASHBOARD_HOST }}
USERNAME: ${{ secrets.DASHBOARD_USERNAME }}
KEY: ${{ secrets.DASHBOARD_SSHKEY }}
script: |
docker pull fluencelabs/dashboard:${{ env.VERSION }}
docker rm -f dashboard
docker run -d --name dashboard -p443:443 -p80:80 -v caddy_data:/data fluencelabs/dashboard:${{ env.VERSION }}

View File

@ -1,5 +1,4 @@
:8080, dash.fluence.dev {
log {
output stderr
format console
@ -8,6 +7,6 @@
tls alexey@fluence.one
encode zstd gzip
file_server
root * /bundle
try_files {path} /index.html
root * /dist
# try_files {path} /index.html
}

View File

@ -1,6 +1,6 @@
FROM caddy
WORKDIR /
COPY ./dist /bundle
COPY ./dist /dist
COPY Caddyfile /Caddyfile
#RUN printf '\n\

View File

@ -1,2 +1,4 @@
FROM nginx
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY dist /usr/share/nginx/html

9
nginx.conf Normal file
View File

@ -0,0 +1,9 @@
server {
listen 80;
server_name frontend;
location / {
# This would be the directory where your React app's static files are stored at
root /usr/share/nginx/html;
try_files $uri /index.html;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "fluence-admin",
"version": "0.0.1",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
@ -8,7 +8,7 @@
"start": "npm run dev",
"dev": "webpack-dev-server --hot --colors --port 3000",
"build": "webpack",
"prod": "webpack -p",
"prod": "webpack -p --mode production",
"analyse": "elm-analyse -s -p 3001 -o",
"compile-aqua": "aqua-cli --js -i ./aqua/ -o ./src/_aqua",
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""

View File

@ -69,7 +69,7 @@ function event(name, peer, peers, identify, services, modules, blueprints) {
/* eslint-enable */
(async () => {
setLogLevel('SILENT');
setLogLevel('DEBUG');
const pid = await generatePeerId();
const flags = genFlags(pid.toB58String());

View File

@ -1,7 +1,7 @@
const path = require('path');
const { merge } = require('webpack-merge');
const ClosurePlugin = require('closure-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
@ -137,19 +137,14 @@ if (MODE === 'development') {
if (MODE === 'production') {
module.exports = merge(common, {
optimization: {
minimize: true,
minimizer: [
new ClosurePlugin(
{ mode: 'STANDARD' },
{
// compiler flags here
//
// for debugging help, try these:
//
// formatting: 'PRETTY_PRINT',
// debug: true
// renaming: false
new TerserPlugin({
parallel: true,
terserOptions: {
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
},
),
}),
new OptimizeCSSAssetsPlugin({}),
],
},