♻️ 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

@ -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 \