0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-20 19:51:23 -05:00

♻️ Refactor on docker and build scripts.

- Migrate to from ubuntu to debian.
- Add new buildenv image.
- Remove production images building from this repo.
- Better comaptibility with other architectures (arm64).
- Improved config management.
This commit is contained in:
Andrey Antukh 2020-01-20 13:03:01 +01:00
parent 655c7ae023
commit f57ce57cb3
26 changed files with 400 additions and 5348 deletions

View file

@ -50,7 +50,7 @@
mount/mount {:mvn/version "0.1.16"}
environ/environ {:mvn/version "1.1.0"}}
:paths ["src" "resources" "../common"]
:paths ["src" "resources" "../common" "common"]
:aliases
{:dev
{:extra-deps

View file

@ -11,6 +11,8 @@
"A configuration management."
(:require
[clojure.tools.logging :as log]
[clojure.spec.alpha :as s]
[uxbox.common.spec :as us]
[cuerdas.core :as str]
[environ.core :refer [env]]
[mount.core :refer [defstate]]
@ -29,37 +31,82 @@
(log/warn (str/istr "can't parse `~{key}` env value"))
default)))))
;; --- Configuration Loading & Parsing
(defn read-config
[]
{:http-server-port (lookup-env env :uxbox-http-server-port 6060)
:http-server-debug (lookup-env env :uxbox-http-server-debug true)
:http-server-cors (lookup-env env :uxbox-http-server-cors "http://localhost:3449")
{:http-server-port (:uxbox-http-server-port env 6060)
:http-server-debug (:uxbox-http-server-debug env true)
:http-server-cors (:uxbox-http-server-cors env "http://localhost:3449")
:database-username (lookup-env env :uxbox-database-username nil)
:database-password (lookup-env env :uxbox-database-password nil)
:database-uri (lookup-env env :uxbox-database-uri "postgresql://127.0.0.1/uxbox")
:media-directory (lookup-env env :uxbox-media-directory "resources/public/media")
:media-uri (lookup-env env :uxbox-media-uri "http://localhost:6060/media/")
:assets-directory (lookup-env env :uxbox-assets-directory "resources/public/static")
:assets-uri (lookup-env env :uxbox-assets-uri "http://localhost:6060/static/")
:database-username (:uxbox-database-username env nil)
:database-password (:uxbox-database-password env nil)
:database-uri (:uxbox-database-uri env "postgresql://127.0.0.1/uxbox")
:media-directory (:uxbox-media-directory env "resources/public/media")
:media-uri (:uxbox-media-uri env "http://localhost:6060/media/")
:assets-directory (:uxbox-assets-directory env "resources/public/static")
:assets-uri (:uxbox-assets-uri env "http://localhost:6060/static/")
:google-api-key (lookup-env env :uxbox-google-api-key nil)
:google-api-key (:uxbox-google-api-key env nil)
:email-reply-to (lookup-env env :uxbox-email-reply-to "no-reply@nodomain.com")
:email-from (lookup-env env :uxbox-email-from "no-reply@nodomain.com")
:email-reply-to (:uxbox-email-reply-to env "no-reply@nodomain.com")
:email-from (:uxbox-email-from env "no-reply@nodomain.com")
:smtp-host (lookup-env env :uxbox-smtp-host "smtp")
:smtp-port (lookup-env env :uxbox-smtp-port 25)
:smtp-user (lookup-env env :uxbox-smtp-user nil)
:smtp-password (lookup-env env :uxbox-smtp-password nil)
:smtp-tls (lookup-env env :uxbox-smtp-tls false)
:smtp-ssl (lookup-env env :uxbox-smtp-ssl false)
:smtp-enabled (lookup-env env :uxbox-smtp-enabled false)
:smtp-host (:uxbox-smtp-host env "smtp")
:smtp-port (:uxbox-smtp-port env 25)
:smtp-user (:uxbox-smtp-user env nil)
:smtp-password (:uxbox-smtp-password env nil)
:smtp-tls (:uxbox-smtp-tls env false)
:smtp-ssl (:uxbox-smtp-ssl env false)
:smtp-enabled (:uxbox-smtp-enabled env false)
:allow-demo-users (lookup-env env :uxbox-allow-demo-users true)
:registration-enabled (lookup-env env :uxbox-registration-enabled true)})
:allow-demo-users (:uxbox-allow-demo-users env true)
:registration-enabled (:uxbox-registration-enabled env true)})
(s/def ::http-server-port ::us/integer)
(s/def ::http-server-debug ::us/boolean)
(s/def ::http-server-cors ::us/string)
(s/def ::database-username (s/nilable ::us/string))
(s/def ::database-password (s/nilable ::us/string))
(s/def ::database-uri ::us/string)
(s/def ::assets-uri ::us/string)
(s/def ::assets-directory ::us/string)
(s/def ::media-uri ::us/string)
(s/def ::media-directory ::us/string)
(s/def ::email-reply-to ::us/email)
(s/def ::email-from ::us/email)
(s/def ::smtp-host ::us/string)
(s/def ::smtp-user (s/nilable ::us/string))
(s/def ::smtp-password (s/nilable ::us/string))
(s/def ::smtp-tls ::us/boolean)
(s/def ::smtp-ssl ::us/boolean)
(s/def ::smtp-enabled ::us/boolean)
(s/def ::allow-demo-users ::us/boolean)
(s/def ::registration-enabled ::us/boolean)
(s/def ::config
(s/keys :req-un [::http-server-cors
::http-server-debug
::http-server-port
::database-username
::database-password
::database-uri
::assets-directory
::assets-uri
::media-directory
::media-uri
::email-reply-to
::email-from
::smtp-host
::smtp-user
::smtp-password
::smtp-tls
::smtp-ssl
::smtp-enabled
::allow-demo-users
::registration-enabled]))
(defn read-test-config
[]
@ -70,7 +117,7 @@
:migrations-verbose false))
(defstate config
:start (read-config))
:start (us/conform ::config (read-config)))
;; --- Secret Loading & Parsing

View file

@ -78,6 +78,9 @@
(vh/server ctx {:handler handler
:port (:http-server-port cfg/config)})))
(defstate instances
:start (.availableProcessors (Runtime/getRuntime)))
(defstate server
:start (let [factory (vc/verticle {:on-start on-start})]
@(vc/deploy! system factory {:instances 1})))
@(vc/deploy! system factory {:instances instances})))

View file

@ -1,7 +1,6 @@
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class

View file

@ -1,4 +1,4 @@
FROM azul/zulu-openjdk:12
FROM debian:buster
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
ENV CLOJURE_VERSION=1.10.1.492 \
@ -12,6 +12,9 @@ RUN set -ex; \
wget \
rsync \
git \
vim \
rlwrap \
openjdk-11-jdk \
imagemagick \
webp

View file

@ -0,0 +1,55 @@
FROM debian:buster
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
ARG DEBIAN_FRONTEND=noninteractive
ENV NODE_VERSION=v12.14.1 \
CLOJURE_VERSION=1.10.1.492 \
LANG=en_US.UTF-8 \
LC_ALL=C.UTF-8
RUN set -ex; \
mkdir -p /etc/resolvconf/resolv.conf.d; \
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail;
RUN set -ex; \
apt-get update && \
apt-get install -yq \
locales \
gnupg2 \
ca-certificates \
wget \
sudo \
vim \
curl \
bash \
git \
rlwrap \
python \
build-essential \
openjdk-11-jdk \
; \
rm -rf /var/lib/apt/lists/*;
COPY files/bashrc /root/.bashrc
COPY files/vimrc /root/.vimrc
COPY files/entrypoint.sh /entrypoint.sh
COPY files/package.json /root/package.json
WORKDIR /root
RUN set -ex; \
wget "https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh"; \
chmod +x "linux-install-$CLOJURE_VERSION.sh"; \
"./linux-install-$CLOJURE_VERSION.sh"; \
rm -rf "linux-install-$CLOJURE_VERSION.sh"
RUN set -ex; \
git clone https://github.com/creationix/nvm.git .nvm; \
bash -c "source .nvm/nvm.sh && nvm install $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm alias default $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm use default";
RUN set -ex; \
bash -c "source .nvm/nvm.sh && npm install";
ENTRYPOINT ["bash", "/entrypoint.sh"]

View file

@ -0,0 +1,12 @@
export PATH=$HOME/.local/bin:$PATH
alias l='ls --color -GFlh'
alias rm='rm -r'
alias ls='ls --color -F'
alias lsd='ls -d *(/)'
alias lsf='ls -h *(.)'
export LEIN_FAST_TRAMPOLINE=y
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

View file

@ -0,0 +1,4 @@
#!/usr/bin/env zsh
set -ex
exec "$@"

26
docker/buildenv/files/vimrc Executable file
View file

@ -0,0 +1,26 @@
set nocompatible
set bs=2
set ts=4
set tw=1000000000
set expandtab
set tabstop=8
set softtabstop=4
set shiftwidth=4
filetype indent off
filetype plugin on
syntax on
set autoindent
set showmatch
set showmode
set mousehide
set nowrapscan
set hlsearch
set incsearch
set fileencoding=utf8
set encoding=utf8

View file

@ -1,4 +1,4 @@
FROM ubuntu:bionic
FROM debian:buster
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
ARG EXTERNAL_UID=1000
@ -9,6 +9,10 @@ ENV NODE_VERSION=v12.14.1 \
LANG=en_US.UTF-8 \
LC_ALL=C.UTF-8
RUN set -ex; \
mkdir -p /etc/resolvconf/resolv.conf.d; \
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail;
RUN set -ex; \
apt-get update && \
apt-get install -yq \
@ -24,45 +28,17 @@ RUN set -ex; \
bash \
git \
rlwrap \
python \
build-essential \
imagemagick \
webp \
openjdk-11-jdk \
; \
rm -rf /var/lib/apt/lists/*;
RUN set -ex; \
mkdir -p /etc/resolvconf/resolv.conf.d; \
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail; \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9; \
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \
echo "deb http://repos.azulsystems.com/ubuntu stable main" >> /etc/apt/sources.list.d/zulu.list; \
echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" >> /etc/apt/sources.list.d/postgresql.list;
RUN set -ex; \
apt-get -qq update; \
apt-get install -qqy zulu-12; \
apt-get install -qqy \
postgresql-12 \
postgresql-contrib-12 \
;\
rm -rf /var/lib/apt/lists/*;
COPY files/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf
COPY files/bashrc /root/.bashrc
COPY files/vimrc /root/.vimrc
RUN set -ex; \
/etc/init.d/postgresql start \
&& createuser -U postgres -sl uxbox \
&& createdb -U uxbox uxbox \
&& createdb -U uxbox test \
&& /etc/init.d/postgresql stop
EXPOSE 3449
EXPOSE 6060
EXPOSE 9090
RUN set -ex; \
useradd -m -g users -s /bin/zsh -u $EXTERNAL_UID uxbox; \
passwd uxbox -d; \
@ -77,12 +53,7 @@ RUN set -ex; \
USER uxbox
WORKDIR /home/uxbox
RUN set -ex; \
git clone https://github.com/creationix/nvm.git .nvm; \
bash -c "source .nvm/nvm.sh && nvm install $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm alias default $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm use default";
COPY files/package.json /home/uxbox/package.json
COPY files/bashrc /home/uxbox/.bashrc
COPY files/zshrc /home/uxbox/.zshrc
COPY files/vimrc /home/uxbox/.vimrc
@ -91,5 +62,18 @@ COPY files/tmux.conf /home/uxbox/.tmux.conf
COPY files/entrypoint.sh /home/uxbox/
COPY files/init.sh /home/uxbox/
RUN set -ex; \
git clone https://github.com/creationix/nvm.git .nvm; \
bash -c "source .nvm/nvm.sh && nvm install $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm alias default $NODE_VERSION"; \
bash -c "source .nvm/nvm.sh && nvm use default";
RUN set -ex; \
bash -c "source .nvm/nvm.sh && npm install";
EXPOSE 3449
EXPOSE 6060
EXPOSE 9090
ENTRYPOINT ["zsh", "/home/uxbox/entrypoint.sh"]
CMD ["/home/uxbox/init.sh"]

View file

@ -14,10 +14,9 @@ volumes:
services:
main:
privileged: true
build:
context: ./
hostname: 'uxboxdev-main'
container_name: 'uxboxdev-main'
image: "uxbox-devenv"
hostname: 'uxbox-devenv-main'
container_name: 'uxbox-devenv-main'
command: "/home/uxbox/init.sh"
stop_signal: SIGINT
depends_on:
@ -25,9 +24,8 @@ services:
- smtp
volumes:
- "user_data:/home/uxbox/local"
- "${PWD}:/home/uxbox/uxbox"
- "${HOME}/.m2:/home/uxbox/.m2"
- "${HOME}/.gitconfig:/home/uxbox/.gitconfig"
- "${PWD}:/home/uxbox/uxbox"
ports:
- 3449:3449
@ -35,13 +33,13 @@ services:
- 9090:9090
environment:
- CLOJURE_OPTS="-J-XX:-OmitStackTraceInFastThrow"
- UXBOX_DATABASE_URI="postgresql://postgres/uxbox"
- UXBOX_DATABASE_USERNAME="uxbox"
- UXBOX_DATABASE_PASSWORD="uxbox"
- CLOJURE_OPTS=-J-XX:-OmitStackTraceInFastThrow
- UXBOX_DATABASE_URI=postgresql://postgres/uxbox
- UXBOX_DATABASE_USERNAME=uxbox
- UXBOX_DATABASE_PASSWORD=uxbox
smtp:
container_name: 'uxboxdev-smtp'
container_name: 'uxbox-devenv-smtp'
image: mwader/postfix-relay
restart: always
environment:
@ -51,14 +49,14 @@ services:
postgres:
image: postgres:12
command: postgres -c config_file=/etc/postgresql.conf
hostname: 'uxboxdev-postgres'
container_name: 'uxboxdev-postgres'
hostname: 'uxbox-devenv-postgres'
container_name: 'uxbox-devenv-postgres'
restart: always
stop_signal: SIGINT
ports:
- 5432:5432
environment:
- POSTGRES_INITDB_ARGS="--data-checksums"
- POSTGRES_INITDB_ARGS=--data-checksums
- POSTGRES_DB=uxbox
- POSTGRES_USER=uxbox
- POSTGRES_PASSWORD=uxbox

View file

@ -8,5 +8,5 @@ alias lsf='ls -h *(.)'
export LEIN_FAST_TRAMPOLINE=y
export NVM_DIR="/home/uxbox/.nvm"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

View file

@ -15,7 +15,6 @@ tmux send-keys -t uxbox './bin/start-dev' enter
tmux rename-window -t uxbox:0 'gulp'
tmux select-window -t uxbox:0
tmux send-keys -t uxbox 'cd uxbox/frontend' enter C-l
tmux send-keys -t uxbox 'if [ ! -e ./node_modules ]; then npm ci; fi' enter C-l
tmux send-keys -t uxbox 'npx gulp watch' enter
tmux -2 attach-session -t uxbox

View file

@ -10,7 +10,7 @@ bindkey -e
autoload -U promptinit
promptinit
prompt zefram
prompt suse
#------------------------------
## Comp stuff
@ -52,5 +52,5 @@ setopt hist_ignore_all_dups
setopt hist_ignore_space
export PATH=$HOME/.local/bin:$PATH
export NVM_DIR="/home/uxbox/.nvm"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

View file

@ -41,7 +41,8 @@ services:
environment:
# HTTP setup
- UXBOX_HTTP_SERVER_CORS=*
# - CLOJURE_OPTIONS=
- UXBOX_HTTP_SERVER_CORS="*"
# Media & Assets
- UXBOX_MEDIA_URI="/media/"

View file

@ -1,4 +1,4 @@
FROM nginx:1.17.3
FROM nginx:1.17.7
LABEL maintainer="Andrey Antukh <niwi@niwi.nz>"
ENV LANG=en_US.UTF-8 \

View file

@ -1,20 +1,19 @@
const gulp = require("gulp");
const scss = require("gulp-sass");
const autoprefixer = require('gulp-autoprefixer');
const rimraf = require("rimraf");
const mustache = require("gulp-mustache");
const rename = require("gulp-rename");
const gulpif = require("gulp-if");
const gzip = require("gulp-gzip");
const cleancss = require("gulp-clean-css");
const fs = require("fs");
const gulp = require("gulp");
const gulpif = require("gulp-if");
const gzip = require("gulp-gzip");
const l = require("lodash");
const mustache = require("gulp-mustache");
const rename = require("gulp-rename");
const rimraf = require("rimraf");
const scss = require("gulp-sass");
const paths = {};
paths.app = "./resources/";
paths.output = "./resources/public/";
paths.dist = "./dist/";
paths.target = "./target/";
paths.dist = "./target/dist/";
paths.scss = paths.app + "styles/**/*.scss";
/***********************************************
@ -34,10 +33,7 @@ gulp.task("dist:clean", function(next) {
});
function makeAutoprefixer() {
return autoprefixer('last 2 version',
'safari 5',
'ios 6',
'android 4');
return autoprefixer('last 2 version');
}
@ -74,12 +70,12 @@ gulp.task("scss:main", scssPipeline({
output: paths.output + "css/"
}));
gulp.task("scss:view", scssPipeline({
input: paths.app + "styles/view.scss",
output: paths.output + "css/"
}));
// gulp.task("scss:view", scssPipeline({
// input: paths.app + "styles/view.scss",
// output: paths.output + "css/"
// }));
gulp.task("scss", gulp.parallel("scss:main", "scss:view"));
gulp.task("scss", gulp.parallel("scss:main"));
function readLocales() {
const path = __dirname + "/resources/locales.json";
@ -125,12 +121,12 @@ gulp.task("template:main", templatePipeline({
output: paths.output
}));
gulp.task("template:view", templatePipeline({
input: paths.app + "templates/view.mustache",
output: paths.output + "view/"
}));
// gulp.task("template:view", templatePipeline({
// input: paths.app + "templates/view.mustache",
// output: paths.output + "view/"
// }));
gulp.task("templates", gulp.parallel("template:view", "template:main"));
gulp.task("templates", gulp.parallel("template:main"));
// Entry Point
@ -157,16 +153,16 @@ gulp.task("dist:clean", function(next) {
// Templates
gulp.task("dist:template:main", templatePipeline({
input: paths.app + "index.mustache",
input: paths.app + "templates/index.mustache",
output: paths.dist,
}));
gulp.task("dist:template:view", templatePipeline({
input: paths.app + "view.mustache",
output: paths.dist + "view/",
}));
// gulp.task("dist:template:view", templatePipeline({
// input: paths.app + "view.mustache",
// output: paths.dist + "view/",
// }));
gulp.task("dist:templates", gulp.parallel("dist:template:view", "dist:template:main"));
gulp.task("dist:templates", gulp.parallel("dist:template:main"));
// Styles
@ -175,12 +171,12 @@ gulp.task("dist:scss:main", scssPipeline({
output: paths.dist + "css/"
}));
gulp.task("dist:scss:view", scssPipeline({
input: paths.app + "styles/view.scss",
output: paths.dist + "css/"
}));
// gulp.task("dist:scss:view", scssPipeline({
// input: paths.app + "styles/view.scss",
// output: paths.dist + "css/"
// }));
gulp.task("dist:scss", gulp.parallel("dist:scss:main", "dist:scss:view"));
gulp.task("dist:scss", gulp.parallel("dist:scss:main"));
// Copy

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>UXBOX - The Open-Source prototyping tool</title>
<link href="/css/main.css?ts={{& ts}}" rel="stylesheet" type="text/css" />
<link href="css/main.css?ts={{& ts}}" rel="stylesheet" type="text/css" />
<link rel="icon" href="/images/favicon.png" />
</head>
<body>
@ -13,8 +13,8 @@
<section id="loader"></section>
<section id="modal"></section>
<script src="/js/cljs_base.js?ts={{& ts}}"></script>
<script src="/js/main.js?ts={{& ts}}"></script>
<script src="js/cljs_base.js?ts={{& ts}}"></script>
<script src="js/main.js?ts={{& ts}}"></script>
<script>uxbox.main.init({{& tr }})</script>
</body>
</html>

16
frontend/scripts/build-app.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
source ~/.bashrc
export NODE_ENV=production;
set -ex
npx gulp dist:clean || exit 1;
npx gulp dist || exit 1;
cp -r ./target/dist ./target/dist2
mv ./target/dist2 ./target/dist/dbg
clojure -Adev tools.clj dist:all || exit 1;
npx gulp dist:gzip || exit 1;

View file

@ -1,13 +0,0 @@
#!/usr/bin/env bash
source ~/.bashrc
set -ex
npm ci
npx gulp dist:clean || exit 1
npx gulp dist || exit 1
clojure -Adev tools.clj dbg-dist:all || exit 1
npx gulp dist:gzip || exit 1

View file

@ -1,16 +0,0 @@
#!/usr/bin/env bash
source ~/.bashrc
set -ex
npm ci
export NODE_ENV=production;
npx gulp dist:clean || exit 1;
npx gulp dist || exit 1;
clojure -Adev tools.clj dist:all || exit 1
npx gulp dist:gzip || exit 1

View file

@ -26,7 +26,7 @@
;; This excludes webworker instantiation on nodejs where
;; the tests are run.
(when (not= *target* "nodejs")
(defonce worker (uw/init "/js/worker.js")))
(defonce worker (uw/init "js/worker.js")))
(defn align-point
[point]

View file

@ -43,7 +43,7 @@
:anon-fn-naming-policy :mapped
:optimizations :none
:infer-externs true
:verbose false
:verbose true
:source-map true
:static-fns false
:pretty-print true
@ -63,9 +63,9 @@
:asset-path "/js"
:modules {:main {:entries #{"uxbox.main"}
:output-to "resources/public/js/main.js"}
:view {:entries #{"uxbox.view"}
:output-to "resources/public/js/view.js"
}}})
;; :view {:entries #{"uxbox.view"}
;; :output-to "resources/public/js/view.js"}
}})
(def worker-build-options
{:main 'uxbox.worker
@ -78,36 +78,42 @@
(-> (merge default-build-options
main-build-options
dist-build-options)
(assoc :output-dir "dist/js")
(assoc-in [:modules :main :output-to] "dist/js/main.js")
(assoc-in [:modules :view :output-to] "dist/js/view.js")))
(assoc :output-dir "target/dist/js/")
(assoc-in [:modules :main :output-to] "target/dist/js/main.js")
#_(assoc-in [:modules :view :output-to] "target/dist/js/view.js")))
(def main-dbg-dist-build-options
(merge main-dist-build-options
{:optimizations :advanced
:pseudo-names true
:pretty-print true}))
(def main-dist-dbg-build-options
(-> (merge main-dist-build-options
{:optimizations :advanced
:pseudo-names true
:pretty-print true})
(assoc :output-dir "target/dist/dbg/js/")
(assoc-in [:modules :main :output-to] "target/dist/dbg/js/main.js")
#_(assoc-in [:modules :view :output-to] "target/dist/dbg/js/view.js")))
(def worker-dist-build-options
(merge default-build-options
worker-build-options
dist-build-options
{:output-to "dist/js/worker.js"
:output-dir "dist/js/worker"
:source-map "dist/js/worker.js.map"}))
{:output-to "target/dist/js/worker.js"
:output-dir "target/dist/js/worker"
:source-map "target/dist/js/worker.js.map"}))
(def worker-dbg-dist-build-options
(def worker-dist-dbg-build-options
(merge worker-dist-build-options
{:optimizations :advanced
:pseudo-names true
:pretty-print true}))
:pretty-print true
:output-to "target/dist/dbg/js/worker.js"
:output-dir "target/dist/dbg/js/worker"
:source-map "target/dist/dbg/js/worker.js.map"}))
;; --- Tasks Definitions
(defmethod task "dist:main"
[args]
(let [cfg main-dist-build-options]
(pprint cfg)
;; (pprint cfg)
(api/build (api/inputs "src") cfg)))
(defmethod task "dist:worker"
@ -116,27 +122,24 @@
;; (pprint cfg)
(api/build (api/inputs "src") cfg)))
(defmethod task "dbg-dist:main"
(defmethod task "dist-dbg:main"
[args]
(let [cfg main-dbg-dist-build-options]
(let [cfg main-dist-dbg-build-options]
;; (pprint cfg)
(api/build (api/inputs "src") cfg)))
(defmethod task "dbg-dist:worker"
(defmethod task "dist-dbg:worker"
[args]
(let [cfg worker-dbg-dist-build-options]
(let [cfg worker-dist-dbg-build-options]
;; (pprint cfg)
(api/build (api/inputs "src") cfg)))
(defmethod task "dist:all"
[args]
(task ["dist:main"])
(task ["dist:worker"]))
(defmethod task "dbg-dist:all"
[args]
(task ["dbg-dist:main"])
(task ["dbg-dist:worker"]))
(task ["dist:worker"])
(task ["dist-dbg:main"])
(task ["dist-dbg:worker"]))
(defmethod task "repl:node"
[args]
@ -157,7 +160,7 @@
(api/build (api/inputs "src" "test")
(assoc default-build-options
:main 'uxbox.tests.main
:verbose false
:verbose true
:target :nodejs
:source-map true
:output-to "target/tests/main.js"

306
manage.sh
View file

@ -2,27 +2,50 @@
set -e
REV=`git log -n 1 --pretty=format:%h -- docker/`
IMGNAME="uxboxdev_main"
function remove-devenv-images {
echo "Clean old development image $IMGNAME..."
docker images $IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi
}
DEVENV_IMGNAME="uxbox-devenv"
BUILDENV_IMGNAME="uxbox-buildenv"
function build-devenv {
echo "Building development image $IMGNAME:latest with UID $EXTERNAL_UID..."
echo "Building development image $DEVENV_IMGNAME:latest with UID $EXTERNAL_UID..."
cp ./frontend/build/package.json docker/devenv/files/package.json;
local EXTERNAL_UID=${1:-$(id -u)}
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml \
build --build-arg EXTERNAL_UID=$EXTERNAL_UID --force-rm;
docker build --rm=true --force-rm \
-t $DEVENV_IMGNAME:latest \
--build-arg EXTERNAL_UID=$EXTERNAL_UID \
docker/devenv/;
rm -rf docker/devenv/files/package.json;
}
function build-buildenv {
echo "Building buildenv image..."
docker volume create ${BUILDENV_IMGNAME}-m2
cp ./frontend/build/package.json docker/buildenv/files/package.json;
docker build --rm=true \
-t $BUILDENV_IMGNAME:latest \
docker/buildenv/;
rm -rf docker/buildenv/files/package.json;
}
function build-devenv-if-not-exists {
if [[ ! $(docker images $IMGNAME:latest -q) ]]; then
if [[ ! $(docker images $DEVENV_IMGNAME:latest -q) ]]; then
build-devenv $@
fi
}
function build-buildenv-if-not-exists {
if [[ ! $(docker images $BUILDENV_IMGNAME:latest -q) ]]; then
build-buildenv $@
fi
}
function start-devenv {
build-devenv-if-not-exists $@;
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml up -d;
@ -34,194 +57,94 @@ function stop-devenv {
function drop-devenv {
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml down -t 2 -v;
remove-devenv-images;
echo "Clean old development image $DEVENV_IMGNAME..."
docker images $DEVENV_IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi
}
function run-devenv {
if [[ ! $(docker ps -f "name=uxboxdev-main" -q) ]]; then
if [[ ! $(docker ps -f "name=uxbox-devenv-main" -q) ]]; then
start-devenv
fi
docker exec -ti uxboxdev-main /home/uxbox/start-tmux.sh
docker exec -ti uxbox-devenv-main /home/uxbox/start-tmux.sh
}
function run-all-tests {
echo "Testing frontend..."
run-frontend-tests $@ || exit 1;
echo "Testing backend..."
run-backend-tests $@ || exit 1;
}
# function run-all-tests {
# echo "Testing frontend..."
# run-frontend-tests $@ || exit 1;
# echo "Testing backend..."
# run-backend-tests $@ || exit 1;
# }
function run-frontend-tests {
build-devenv-if-not-exists $@;
# function run-frontend-tests {
# build-devenv-if-not-exists $@;
CONTAINER=$IMGNAME:latest
# IMAGE=$DEVENV_IMGNAME:latest
echo "Running development image $CONTAINER to test backend..."
docker run -ti --rm \
-w /home/uxbox/uxbox/frontend \
-v `pwd`:/home/uxbox/uxbox \
-v $HOME/.m2:/home/uxbox/.m2 \
$CONTAINER ./scripts/build-and-run-tests.sh
}
# echo "Running development image $CONTAINER to test backend..."
# docker run -ti --rm \
# -w /home/uxbox/uxbox/frontend \
# -v `pwd`:/home/uxbox/uxbox \
# -v $HOME/.m2:/home/uxbox/.m2 \
# $IMAGE ./scripts/build-and-run-tests.sh
# }
function run-backend-tests {
build-devenv-if-not-exists $@;
# function run-backend-tests {
# build-devenv-if-not-exists $@;
CONTAINER=$IMGNAME:latest
# IMAGE=$DEVENV_IMGNAME:latest
docker run -ti --rm \
-w /home/uxbox/uxbox/backend \
-v `pwd`:/home/uxbox/uxbox \
-v $HOME/.m2:/home/uxbox/.m2 \
$CONTAINER ./scripts/run-tests-in-docker.sh
}
# docker run -ti --rm \
# -w /home/uxbox/uxbox/backend \
# -v `pwd`:/home/uxbox/uxbox \
# -v $HOME/.m2:/home/uxbox/.m2 \
# $IMAGE ./scripts/run-tests-in-docker.sh
# }
function build-frontend-local {
build-devenv-if-not-exists;
function build-frontend {
build-buildenv-if-not-exists;
mkdir -p $HOME/.m2
rm -rf ./frontend/node_modules
local IMAGE=$BUILDENV_IMGNAME:latest;
CONTAINER=$IMGNAME:latest;
BUILD_TYPE=$1;
echo "Running development image $CONTAINER to build frontend $BUILD_TYPE ..."
docker run -ti --rm \
-w /home/uxbox/uxbox/frontend \
-v `pwd`:/home/uxbox/uxbox \
-v $HOME/.m2:/home/uxbox/.m2 \
echo "Running development image $IMAGE to build frontend."
docker run -t --rm \
--mount source=`pwd`,type=bind,target=/root/uxbox \
--mount source=${BUILDENV_IMGNAME}-m2,target=/root/.m2 \
-w /root/uxbox/frontend \
-e UXBOX_API_URL="/api" \
-e UXBOX_VIEW_URL="/view" \
-e UXBOX_DEMO_WARNING=true \
$CONTAINER ./scripts/build-$BUILD_TYPE.sh
$IMAGE ./scripts/build-app.sh
}
function build-frontend-image {
echo "#############################################"
echo "## START build 'uxbox-frontend' image. ##"
echo "#############################################"
build-frontend-local "dist" || exit 1;
rm -rf docker/frontend/dist || exit 1;
cp -vr frontend/dist docker/frontend/ || exit 1;
docker build --rm=true \
-t uxbox-frontend:$REV \
-t uxbox-frontend:latest \
docker/frontend/;
rm -rf docker/frontend/dist || exit 1;
echo "#############################################"
echo "## END build 'uxbox-frontend' image. ##"
echo "#############################################"
}
function build-frontend-dbg-image {
echo "#############################################"
echo "## START build 'uxbox-frontend-dbg' image. ##"
echo "#############################################"
build-frontend-local "dbg-dist" || exit 1;
rm -rf docker/frontend/dist || exit 1;
cp -vr frontend/dist docker/frontend/ || exit 1;
docker build --rm=true \
-t uxbox-frontend-dbg:$REV \
-t uxbox-frontend-dbg:latest \
docker/frontend/;
rm -rf docker/frontend/dist || exit 1;
echo "#############################################"
echo "## END build 'uxbox-frontend-dbg' image. ##"
echo "#############################################"
}
function build-backend-local {
echo "Prepare backend dist..."
rm -rf ./backend/dist
function build-backend {
rm -rf ./backend/target/dist
mkdir -p ./backend/target/dist
rsync -ar \
--exclude="/test" \
--exclude="/resources/public/media" \
--exclude="/target" \
--exclude="/scripts" \
--exclude="/.*" \
./backend/ ./backend/dist/
}
--exclude="/tests*" \
--exclude="/resources/public/media" \
--exclude="/file-uploads" \
--exclude="/target" \
--exclude="/scripts" \
--exclude="/.*" \
./backend/ ./backend/target/dist/
function build-backend-image {
echo "#############################################"
echo "## START build 'uxbox-backend' image. ##"
echo "#############################################"
build-backend-local || exit 1;
rm -rf docker/backend/dist || exit 1;
cp -vr backend/dist docker/backend/ || exit 1;
docker build --rm=true \
-t uxbox-backend:$REV \
-t uxbox-backend:latest \
docker/backend/;
rm -rf docker/backend/dist || exit 1;
echo "#############################################"
echo "## END build 'uxbox-backend' image. ##"
echo "#############################################"
}
function build-images {
build-devenv-if-not-exists $@;
echo "Building frontend image ..."
build-frontend-image || exit 1;
echo "Building frontend dbg image ..."
build-frontend-dbg-image || exit 1;
echo "Building backend image ..."
build-backend-image || exit 1;
}
function run {
if [[ ! $(docker images uxbox-backend:latest) ]]; then
build-backend-image
fi
if [[ ! $(docker images uxbox-frontend:latest) ]]; then
build-frontend-image
fi
if [[ ! $(docker images uxbox-frontend-dbg:latest) ]]; then
build-frontend-dbg-image
fi
echo "Running images..."
docker-compose -p uxbox -f ./docker/docker-compose.yml up -d
}
function log {
docker-compose -p uxbox -f docker/docker-compose.yml logs -f --tail=50
rsync -ar \
./common/ ./backend/target/dist/common/
}
function log-devenv {
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml logs -f --tail=50
}
function stop {
echo "Stoping containers..."
docker-compose -p uxbox -f ./docker/docker-compose.yml stop
}
function drop {
docker-compose -p uxbox -f docker/docker-compose.yml down -t 2 -v;
}
function usage {
echo "UXBOX build & release manager v$REV"
echo "USAGE: $0 OPTION"
echo "Options:"
echo "- clean Stop and clean up docker containers"
echo ""
# echo "- clean Stop and clean up docker containers"
# echo ""
echo "- build-devenv Build docker development oriented image; (can specify external user id in parameter)"
echo "- start-devenv Start the development oriented docker-compose service."
echo "- stop-devenv Stops the development oriented docker-compose service."
@ -244,12 +167,11 @@ function usage {
}
case $1 in
clean)
remove-devenv-images
build-buildenv)
build-buildenv ${@:2}
;;
## devenv related commands
build-devenv)
build-devenv ${@:2}
;;
@ -271,45 +193,23 @@ case $1 in
## testin related commands
run-all-tests)
run-all-tests ${@:2}
;;
run-frontend-tests)
run-frontend-tests ${@:2}
;;
run-backend-tests)
run-backend-tests ${@:2}
# run-all-tests)
# run-all-tests ${@:2}
# ;;
# run-frontend-tests)
# run-frontend-tests ${@:2}
# ;;
# run-backend-tests)
# run-backend-tests ${@:2}
# ;;
# production builds
build-frontend)
build-frontend
;;
# production related comands
build-images)
build-images
;;
build-frontend-dbg-image)
build-frontend-dbg-image
;;
build-frontend-image)
build-frontend-image
;;
build-backend-image)
build-backend-image
;;
run)
run
;;
log)
log
;;
stop)
stop
;;
drop)
drop
build-backend)
build-backend
;;
*)