mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
misc: improve management scripts
This commit is contained in:
parent
1fbd353001
commit
fd53f07efe
8 changed files with 62 additions and 57 deletions
|
@ -2,5 +2,4 @@
|
|||
|
||||
set -x
|
||||
|
||||
sudo pg_ctlcluster 9.6 main start
|
||||
clj -Adev -m uxbox.tests.main
|
||||
|
|
|
@ -30,12 +30,12 @@ RUN set -ex; \
|
|||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
RUN set -ex; \
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list; \
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list; \
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \
|
||||
apt-get update -yq && \
|
||||
apt-get install -yq \
|
||||
postgresql-9.6 \
|
||||
postgresql-contrib-9.6 \
|
||||
postgresql-11 \
|
||||
postgresql-contrib-11 \
|
||||
;\
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
|
@ -43,7 +43,7 @@ RUN set -ex; \
|
|||
mkdir -p /etc/resolvconf/resolv.conf.d; \
|
||||
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail;
|
||||
|
||||
COPY files/pg_hba.conf /etc/postgresql/9.6/main/pg_hba.conf
|
||||
COPY files/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
|
||||
COPY files/bashrc /root/.bashrc
|
||||
COPY files/vimrc /root/.vimrc
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
set -e
|
||||
echo "UXBOX Docker Dev entrypoint initialization..."
|
||||
set -ex
|
||||
sudo pg_ctlcluster 11 main start
|
||||
|
||||
exec "$@"
|
||||
|
|
|
@ -13,10 +13,6 @@ tmux send-keys -t uxbox 'cd uxbox/backend' enter C-l
|
|||
tmux send-keys -t uxbox 'clojure -Adev -m uxbox.fixtures' enter C-l
|
||||
tmux send-keys -t uxbox 'clojure -Adev:repl' enter
|
||||
|
||||
tmux new-window -t uxbox:3 -n 'services'
|
||||
tmux select-window -t uxbox:3
|
||||
tmux send-keys -t uxbox 'sudo pg_ctlcluster 9.6 main start' 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
|
||||
|
|
|
@ -10,11 +10,11 @@ networks:
|
|||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.177.57.0/24
|
||||
- subnet: 172.177.12.0/24
|
||||
|
||||
services:
|
||||
uxdb:
|
||||
image: postgres:latest
|
||||
image: postgres:11
|
||||
container_name: uxdb
|
||||
restart: always
|
||||
ports:
|
||||
|
@ -32,7 +32,7 @@ services:
|
|||
uxbackend:
|
||||
image: uxbox-backend:latest
|
||||
container_name: uxbackend
|
||||
restart: always
|
||||
# restart: always
|
||||
depends_on:
|
||||
- uxdb
|
||||
ports:
|
||||
|
|
|
@ -32,5 +32,5 @@ WORKDIR /srv/uxbox/
|
|||
|
||||
EXPOSE 6060
|
||||
|
||||
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
||||
ENTRYPOINT ["bash", "/entrypoint.sh"]
|
||||
CMD ["clojure", "-m", "uxbox.main"]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# Once application has been built, prepare production image
|
||||
FROM nginx:alpine
|
||||
|
||||
LABEL maintainer="Monogramm Maintainers <opensource at monogramm dot io>"
|
||||
|
|
93
manage.sh
93
manage.sh
|
@ -2,35 +2,37 @@
|
|||
set -e
|
||||
|
||||
REV=`git log -n 1 --pretty=format:%h -- docker/`
|
||||
IMGNAME="uxbox"
|
||||
IMGNAME="uxbox-devenv"
|
||||
|
||||
function kill-container {
|
||||
function kill-devenv-container {
|
||||
echo "Cleaning development container $IMGNAME:$REV..."
|
||||
if $(docker ps | grep -q $IMGNAME); then
|
||||
docker ps | grep $IMGNAME | awk '{print $1}' | xargs --no-run-if-empty docker kill
|
||||
fi
|
||||
if $(docker ps -a | grep -q $IMGNAME); then
|
||||
docker ps -a | grep $IMGNAME | awk '{print $1}' | xargs --no-run-if-empty docker rm
|
||||
fi
|
||||
docker ps -a -f name=$IMGNAME -q | xargs --no-run-if-empty docker kill
|
||||
}
|
||||
|
||||
function remove-image {
|
||||
function remove-devenv-images {
|
||||
echo "Clean old development image $IMGNAME..."
|
||||
docker images | grep $IMGNAME | awk '{print $3}' | xargs --no-run-if-empty docker rmi
|
||||
docker images $IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi
|
||||
}
|
||||
|
||||
function build-devenv {
|
||||
kill-container
|
||||
echo "Building development image $IMGNAME:$REV..."
|
||||
docker build --rm=true -t $IMGNAME:$REV --build-arg EXTERNAL_UID=$(id -u) -t $IMGNAME:latest docker/devenv
|
||||
docker build --rm=true \
|
||||
-t $IMGNAME:$REV \
|
||||
-t $IMGNAME:latest \
|
||||
--build-arg EXTERNAL_UID=$(id -u) \
|
||||
--label="io.uxbox.devenv" \
|
||||
docker/devenv
|
||||
}
|
||||
|
||||
function build-devenv-if-not-exists {
|
||||
if [[ ! $(docker images $IMGNAME:$REV -q) ]]; then
|
||||
build-devenv
|
||||
fi
|
||||
}
|
||||
|
||||
function run-devenv {
|
||||
kill-container
|
||||
|
||||
if ! $(docker images | grep $IMGNAME | grep -q $REV); then
|
||||
build-devenv
|
||||
fi
|
||||
kill-devenv-container;
|
||||
build-devenv-if-not-exists;
|
||||
|
||||
mkdir -p $HOME/.m2
|
||||
rm -rf ./frontend/node_modules
|
||||
|
@ -46,6 +48,7 @@ function run-devenv {
|
|||
-v $HOME/.m2:/home/uxbox/.m2 \
|
||||
-v $HOME/.gitconfig:/home/uxbox/.gitconfig \
|
||||
-p 3449:3449 -p 6060:6060 -p 9090:9090 \
|
||||
--name "uxbox-devenv" \
|
||||
$CONTAINER
|
||||
}
|
||||
|
||||
|
@ -57,24 +60,20 @@ function run-all-tests {
|
|||
}
|
||||
|
||||
function run-frontend-tests {
|
||||
if ! $(docker images | grep $IMGNAME | grep -q $REV); then
|
||||
build-devenv
|
||||
fi
|
||||
build-devenv-if-not-exists;
|
||||
|
||||
CONTAINER=$IMGNAME:latest
|
||||
CONTAINER=$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 \
|
||||
$CONTAINER ./scripts/build-and-run-tests.sh
|
||||
}
|
||||
|
||||
function run-backend-tests {
|
||||
if ! $(docker images | grep $IMGNAME | grep -q $REV); then
|
||||
build-devenv
|
||||
fi
|
||||
build-devenv-if-not-exists;
|
||||
|
||||
CONTAINER=$IMGNAME:latest
|
||||
|
||||
|
@ -86,9 +85,7 @@ function run-backend-tests {
|
|||
}
|
||||
|
||||
function build-release-frontend-local {
|
||||
if ! $(docker images | grep $IMGNAME | grep -q $REV); then
|
||||
build-devenv
|
||||
fi
|
||||
build-devenv-if-not-exists;
|
||||
|
||||
mkdir -p $HOME/.m2
|
||||
rm -rf ./frontend/node_modules
|
||||
|
@ -108,14 +105,21 @@ function build-release-frontend-local {
|
|||
function build-release-frontend {
|
||||
build-release-frontend-local || exit 1;
|
||||
rm -rf docker/release.frontend/dist || exit 1;
|
||||
cp -r frontend/dist docker/release.frontend/ || exit 1;
|
||||
docker build --rm=true -t ${IMGNAME}-frontend:$REV -t ${IMGNAME}-frontend:latest docker/release.frontend/
|
||||
cp -vr frontend/dist docker/release.frontend/ || exit 1;
|
||||
|
||||
docker build --rm=true \
|
||||
-t ${IMGNAME}-frontend:$REV \
|
||||
-t ${IMGNAME}-frontend:latest \
|
||||
docker/release.frontend/;
|
||||
|
||||
rm -rf docker/release.frontend/dist || exit 1;
|
||||
}
|
||||
|
||||
function build-release-backend-local {
|
||||
echo "Prepare backend release..."
|
||||
|
||||
rm -rf ./backend/dist
|
||||
|
||||
rsync -avr \
|
||||
--exclude="/test" \
|
||||
--exclude="/resources/public/media" \
|
||||
|
@ -128,8 +132,13 @@ function build-release-backend-local {
|
|||
function build-release-backend {
|
||||
build-release-backend-local || exit 1;
|
||||
rm -rf docker/release.backend/dist || exit 1;
|
||||
cp -r backend/dist docker/release.backend/ || exit 1;
|
||||
docker build --rm=true -t ${IMGNAME}-backend:$REV -t ${IMGNAME}-backend:latest docker/release.backend/
|
||||
cp -vr backend/dist docker/release.backend/ || exit 1;
|
||||
|
||||
docker build --rm=true \
|
||||
-t ${IMGNAME}-backend:$REV \
|
||||
-t ${IMGNAME}-backend:latest \
|
||||
docker/release.backend/;
|
||||
|
||||
rm -rf docker/release.backend/dist || exit 1;
|
||||
}
|
||||
|
||||
|
@ -141,9 +150,11 @@ function build-release {
|
|||
}
|
||||
|
||||
function run-release {
|
||||
kill-container
|
||||
if [[ ! $(docker images uxbox-backend:latest) ]]; then
|
||||
build-release
|
||||
fi
|
||||
|
||||
if ! $(docker images | grep $IMGNAME-backend | grep -q $REV); then
|
||||
if [[ ! $(docker images uxbox-frontend:latest) ]]; then
|
||||
build-release
|
||||
fi
|
||||
|
||||
|
@ -169,8 +180,8 @@ function usage {
|
|||
|
||||
case $1 in
|
||||
clean)
|
||||
kill-container
|
||||
remove-image
|
||||
kill-devenv-container
|
||||
remove-devenv-images
|
||||
;;
|
||||
build-devenv)
|
||||
build-devenv
|
||||
|
|
Loading…
Add table
Reference in a new issue