Pārlūkot izejas kodu

:wrench: init dockerfiles

Jeremy Zheng 1 gadu atpakaļ
vecāks
revīzija
687ba5264b

+ 3 - 0
docker/.gitignore

@@ -0,0 +1,3 @@
+*.tar
+*.tar.??
+*.md5

+ 24 - 0
docker/README.md

@@ -0,0 +1,24 @@
+# Usage
+
+## Podman setup
+
+```bash
+# For Ubuntu
+sudo apt install crun podman buildah fuse-overlayfs
+# For ArchLinux
+sudo pacman -S crun podman buildah fuse-overlayfs
+```
+
+- Merge file `~/.config/containers/storage.conf` and `~/.config/containers/registries.conf`
+
+- Disable build cache `podman build --no-cache NAME`
+
+## Podman commands
+
+```bash
+podman image prune # removes all dangling images
+podman system reset # clean
+podman images # show images
+podman ps -a # show containers
+podman load -i tmp/mint-CODE-TIMESTAMP.tar.xz # import image
+```

+ 43 - 0
docker/backend/Dockerfile

@@ -0,0 +1,43 @@
+FROM ubuntu:latest
+LABEL maintainer="Jeremy Zheng"
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt update
+RUN apt -y upgrade
+
+RUN apt -y install zsh git locales locales-all \
+    vim tzdata zip unzip tree tmux \
+    build-essential
+
+RUN apt -y autoremove
+RUN apt -y clean
+
+RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
+RUN locale-gen
+RUN update-locale LANG=en_US.UTF-8
+RUN update-alternatives --set editor /usr/bin/vim.basic
+
+RUN mkdir -p $HOME/downloads $HOME/build $HOME/local $HOME/tmp
+
+# https://github.com/ohmyzsh/ohmyzsh
+RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
+RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
+RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.zshrc
+RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.zshrc
+RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.zshrc
+
+RUN git config --global core.quotepath false \
+    && git config --global http.version HTTP/1.1 \
+    && git config --global pull.rebase false \
+    && git config --global url."https://".insteadOf git://
+RUN echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf \
+    && echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
+
+
+RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
+
+VOLUME /workspace
+WORKDIR /workspace
+
+CMD ["/bin/zsh", "-l"]

+ 15 - 0
docker/backend/build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+export VERSION=$(date "+%4Y%m%d%H%M%S")
+export CODE="mint-backend"
+
+podman pull ubuntu:latest
+podman build -t $CODE .
+podman save --format=oci-archive -o $CODE-$VERSION.tar $CODE
+md5sum $CODE-$VERSION.tar >$CODE-$VERSION.md5
+
+echo "done($CODE-$VERSION.tar)."
+
+exit 0

+ 10 - 0
docker/backend/start.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+export CODE="mint-backend"
+export NAME="$CODE-$USER"
+
+if podman container exists $NAME; then
+    podman start -i -a $NAME
+else
+    podman run --name $NAME -it --events-backend=file --hostname=mint --network host -v $PWD:/workspace:z $CODE
+fi

+ 51 - 0
docker/frontend/Dockerfile

@@ -0,0 +1,51 @@
+FROM ubuntu:latest
+LABEL maintainer="Jeremy Zheng"
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt update
+RUN apt -y upgrade
+
+RUN apt -y install zsh git locales locales-all \
+    vim tzdata zip unzip tree tmux \
+    build-essential
+
+RUN apt -y autoremove
+RUN apt -y clean
+
+RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
+RUN locale-gen
+RUN update-locale LANG=en_US.UTF-8
+RUN update-alternatives --set editor /usr/bin/vim.basic
+
+RUN mkdir -p $HOME/downloads $HOME/build $HOME/local $HOME/tmp
+
+# https://github.com/ohmyzsh/ohmyzsh
+RUN git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
+RUN cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
+RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.zshrc
+RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.zshrc
+RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.zshrc
+
+RUN git config --global core.quotepath false \
+    && git config --global http.version HTTP/1.1 \
+    && git config --global pull.rebase false \
+    && git config --global url."https://".insteadOf git://
+RUN echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf \
+    && echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
+
+# https://github.com/nvm-sh/nvm
+ENV NVM_VERSION "v0.40.1"
+RUN git clone -b ${NVM_VERSION} https://github.com/nvm-sh/nvm.git $HOME/.nvm
+RUN echo 'export NVM_DIR="$HOME/.nvm"' >> $HOME/.zshrc
+RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.zshrc
+RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $HOME/.zshrc
+RUN zsh -c "source $HOME/.zshrc \
+    && nvm install --lts"
+
+RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
+
+VOLUME /workspace
+WORKDIR /workspace
+
+CMD ["/bin/zsh", "-l"]

+ 15 - 0
docker/frontend/build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+export VERSION=$(date "+%4Y%m%d%H%M%S")
+export CODE="mint-frontend"
+
+podman pull ubuntu:latest
+podman build -t $CODE .
+podman save --format=oci-archive -o $CODE-$VERSION.tar $CODE
+md5sum $CODE-$VERSION.tar >$CODE-$VERSION.md5
+
+echo "done($CODE-$VERSION.tar)."
+
+exit 0

+ 10 - 0
docker/frontend/start.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+export CODE="mint-frontend"
+export NAME="$CODE-$USER"
+
+if podman container exists $NAME; then
+    podman start -i -a $NAME
+else
+    podman run --name $NAME -it --events-backend=file --hostname=mint --network host -v $PWD:/workspace:z $CODE
+fi

+ 27 - 0
docker/laravel/Dockerfile

@@ -0,0 +1,27 @@
+FROM ubuntu:latest
+LABEL maintainer="Jeremy Zheng"
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt update
+RUN apt -y upgrade
+
+RUN apt -y install build-essential
+
+RUN apt -y autoremove
+RUN apt -y clean
+
+RUN apt -y install locales locales-all tzdata build-essential
+
+RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
+RUN locale-gen
+RUN update-locale LANG=en_US.UTF-8
+RUN update-alternatives --set editor /usr/bin/vim.basic
+
+
+RUN echo "$(date -u +%4Y%m%d%H%M%S)" | tee /VERSION
+
+VOLUME /workspace
+WORKDIR /workspace
+
+CMD ["/bin/bash", "-l"]

+ 15 - 0
docker/laravel/build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+export VERSION=$(date "+%4Y%m%d%H%M%S")
+export CODE="mint-laravel"
+
+podman pull ubuntu:latest
+podman build -t $CODE .
+podman save --format=oci-archive -o $CODE-$VERSION.tar $CODE
+md5sum $CODE-$VERSION.tar >$CODE-$VERSION.md5
+
+echo "done($CODE-$VERSION.tar)."
+
+exit 0

+ 10 - 0
docker/laravel/start.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+export CODE="mint-laravel"
+export NAME="$CODE-$USER"
+
+if podman container exists $NAME; then
+    podman start -i -a $NAME
+else
+    podman run --name $NAME -it --events-backend=file --hostname=mint --network host -v $PWD:/workspace:z $CODE
+fi

+ 1 - 0
docker/registries.conf

@@ -0,0 +1 @@
+unqualified-search-registries = ["docker.io"]

+ 6 - 0
docker/storage.conf

@@ -0,0 +1,6 @@
+[storage]
+driver = "overlay"
+rootless_storage_path = "$HOME/.c"
+
+[storage.options.overlay]
+mount_program = "/usr/bin/fuse-overlayfs"