0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 22:22:43 -05:00

misc: improve management scripts

This commit is contained in:
Andrey Antukh 2019-07-03 17:49:15 +02:00
parent 1fbd353001
commit fd53f07efe
8 changed files with 62 additions and 57 deletions

View file

@ -2,5 +2,4 @@
set -x set -x
sudo pg_ctlcluster 9.6 main start
clj -Adev -m uxbox.tests.main clj -Adev -m uxbox.tests.main

View file

@ -30,12 +30,12 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
RUN set -ex; \ 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 -; \ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \
apt-get update -yq && \ apt-get update -yq && \
apt-get install -yq \ apt-get install -yq \
postgresql-9.6 \ postgresql-11 \
postgresql-contrib-9.6 \ postgresql-contrib-11 \
;\ ;\
rm -rf /var/lib/apt/lists/*; rm -rf /var/lib/apt/lists/*;
@ -43,7 +43,7 @@ RUN set -ex; \
mkdir -p /etc/resolvconf/resolv.conf.d; \ mkdir -p /etc/resolvconf/resolv.conf.d; \
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail; 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/bashrc /root/.bashrc
COPY files/vimrc /root/.vimrc COPY files/vimrc /root/.vimrc

View file

@ -1,5 +1,5 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
set -e set -ex
echo "UXBOX Docker Dev entrypoint initialization..." sudo pg_ctlcluster 11 main start
exec "$@" exec "$@"

View file

@ -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 -m uxbox.fixtures' enter C-l
tmux send-keys -t uxbox 'clojure -Adev:repl' enter 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 rename-window -t uxbox:0 'gulp'
tmux select-window -t uxbox:0 tmux select-window -t uxbox:0
tmux send-keys -t uxbox 'cd uxbox/frontend' enter C-l tmux send-keys -t uxbox 'cd uxbox/frontend' enter C-l

View file

@ -10,11 +10,11 @@ networks:
driver: bridge driver: bridge
ipam: ipam:
config: config:
- subnet: 172.177.57.0/24 - subnet: 172.177.12.0/24
services: services:
uxdb: uxdb:
image: postgres:latest image: postgres:11
container_name: uxdb container_name: uxdb
restart: always restart: always
ports: ports:
@ -32,7 +32,7 @@ services:
uxbackend: uxbackend:
image: uxbox-backend:latest image: uxbox-backend:latest
container_name: uxbackend container_name: uxbackend
restart: always # restart: always
depends_on: depends_on:
- uxdb - uxdb
ports: ports:

View file

@ -32,5 +32,5 @@ WORKDIR /srv/uxbox/
EXPOSE 6060 EXPOSE 6060
ENTRYPOINT ["sh", "/entrypoint.sh"] ENTRYPOINT ["bash", "/entrypoint.sh"]
CMD ["clojure", "-m", "uxbox.main"] CMD ["clojure", "-m", "uxbox.main"]

View file

@ -1,4 +1,3 @@
# Once application has been built, prepare production image
FROM nginx:alpine FROM nginx:alpine
LABEL maintainer="Monogramm Maintainers <opensource at monogramm dot io>" LABEL maintainer="Monogramm Maintainers <opensource at monogramm dot io>"

View file

@ -2,35 +2,37 @@
set -e set -e
REV=`git log -n 1 --pretty=format:%h -- docker/` 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..." echo "Cleaning development container $IMGNAME:$REV..."
if $(docker ps | grep -q $IMGNAME); then docker ps -a -f name=$IMGNAME -q | xargs --no-run-if-empty docker kill
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
} }
function remove-image { function remove-devenv-images {
echo "Clean old development image $IMGNAME..." 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 { function build-devenv {
kill-container
echo "Building development image $IMGNAME:$REV..." 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 { function run-devenv {
kill-container kill-devenv-container;
build-devenv-if-not-exists;
if ! $(docker images | grep $IMGNAME | grep -q $REV); then
build-devenv
fi
mkdir -p $HOME/.m2 mkdir -p $HOME/.m2
rm -rf ./frontend/node_modules rm -rf ./frontend/node_modules
@ -46,6 +48,7 @@ function run-devenv {
-v $HOME/.m2:/home/uxbox/.m2 \ -v $HOME/.m2:/home/uxbox/.m2 \
-v $HOME/.gitconfig:/home/uxbox/.gitconfig \ -v $HOME/.gitconfig:/home/uxbox/.gitconfig \
-p 3449:3449 -p 6060:6060 -p 9090:9090 \ -p 3449:3449 -p 6060:6060 -p 9090:9090 \
--name "uxbox-devenv" \
$CONTAINER $CONTAINER
} }
@ -57,24 +60,20 @@ function run-all-tests {
} }
function run-frontend-tests { function run-frontend-tests {
if ! $(docker images | grep $IMGNAME | grep -q $REV); then build-devenv-if-not-exists;
build-devenv
fi
CONTAINER=$IMGNAME:latest CONTAINER=$IMGNAME:latest
echo "Running development image $CONTAINER to test backend..." echo "Running development image $CONTAINER to test backend..."
docker run -ti --rm \ docker run -ti --rm \
-w /home/uxbox/uxbox/frontend \ -w /home/uxbox/uxbox/frontend \
-v `pwd`:/home/uxbox/uxbox \ -v `pwd`:/home/uxbox/uxbox \
-v $HOME/.m2:/home/uxbox/.m2 \ -v $HOME/.m2:/home/uxbox/.m2 \
$CONTAINER ./scripts/build-and-run-tests.sh $CONTAINER ./scripts/build-and-run-tests.sh
} }
function run-backend-tests { function run-backend-tests {
if ! $(docker images | grep $IMGNAME | grep -q $REV); then build-devenv-if-not-exists;
build-devenv
fi
CONTAINER=$IMGNAME:latest CONTAINER=$IMGNAME:latest
@ -86,9 +85,7 @@ function run-backend-tests {
} }
function build-release-frontend-local { function build-release-frontend-local {
if ! $(docker images | grep $IMGNAME | grep -q $REV); then build-devenv-if-not-exists;
build-devenv
fi
mkdir -p $HOME/.m2 mkdir -p $HOME/.m2
rm -rf ./frontend/node_modules rm -rf ./frontend/node_modules
@ -108,14 +105,21 @@ function build-release-frontend-local {
function build-release-frontend { function build-release-frontend {
build-release-frontend-local || exit 1; build-release-frontend-local || exit 1;
rm -rf docker/release.frontend/dist || exit 1; rm -rf docker/release.frontend/dist || exit 1;
cp -r frontend/dist docker/release.frontend/ || exit 1; cp -vr frontend/dist docker/release.frontend/ || exit 1;
docker build --rm=true -t ${IMGNAME}-frontend:$REV -t ${IMGNAME}-frontend:latest docker/release.frontend/
docker build --rm=true \
-t ${IMGNAME}-frontend:$REV \
-t ${IMGNAME}-frontend:latest \
docker/release.frontend/;
rm -rf docker/release.frontend/dist || exit 1; rm -rf docker/release.frontend/dist || exit 1;
} }
function build-release-backend-local { function build-release-backend-local {
echo "Prepare backend release..." echo "Prepare backend release..."
rm -rf ./backend/dist
rsync -avr \ rsync -avr \
--exclude="/test" \ --exclude="/test" \
--exclude="/resources/public/media" \ --exclude="/resources/public/media" \
@ -128,8 +132,13 @@ function build-release-backend-local {
function build-release-backend { function build-release-backend {
build-release-backend-local || exit 1; build-release-backend-local || exit 1;
rm -rf docker/release.backend/dist || exit 1; rm -rf docker/release.backend/dist || exit 1;
cp -r backend/dist docker/release.backend/ || exit 1; cp -vr backend/dist docker/release.backend/ || exit 1;
docker build --rm=true -t ${IMGNAME}-backend:$REV -t ${IMGNAME}-backend:latest docker/release.backend/
docker build --rm=true \
-t ${IMGNAME}-backend:$REV \
-t ${IMGNAME}-backend:latest \
docker/release.backend/;
rm -rf docker/release.backend/dist || exit 1; rm -rf docker/release.backend/dist || exit 1;
} }
@ -141,9 +150,11 @@ function build-release {
} }
function run-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 build-release
fi fi
@ -169,8 +180,8 @@ function usage {
case $1 in case $1 in
clean) clean)
kill-container kill-devenv-container
remove-image remove-devenv-images
;; ;;
build-devenv) build-devenv)
build-devenv build-devenv