mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-18 10:47:31 -08:00
add dev container template
This commit is contained in:
parent
53ca47a5fb
commit
be046acb9e
57
resources/templates/dev_containers/Dockerfile
Normal file
57
resources/templates/dev_containers/Dockerfile
Normal file
@ -0,0 +1,57 @@
|
||||
FROM fedora:latest
|
||||
|
||||
ENV TERM xterm-256color
|
||||
|
||||
###############################################################################
|
||||
# install
|
||||
###############################################################################
|
||||
|
||||
# base
|
||||
RUN dnf install -y \
|
||||
git \
|
||||
git-lfs \
|
||||
python \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-tornado \ # for WebAgg matplotlib
|
||||
gcc \
|
||||
gcc-c++ \
|
||||
make \
|
||||
openssl-devel \
|
||||
libffi-devel \
|
||||
redhat-rpm-config \
|
||||
vim \
|
||||
tmux \
|
||||
hostname \
|
||||
&& dnf clean all
|
||||
|
||||
# user
|
||||
RUN dnf install -y \
|
||||
neovim
|
||||
|
||||
|
||||
###############################################################################
|
||||
# general
|
||||
###############################################################################
|
||||
|
||||
# add user
|
||||
RUN useradd -u 1000 -g 100 -ms /bin/bash dev \
|
||||
&& echo 'dev:pass' | chpasswd
|
||||
RUN usermod -aG wheel dev
|
||||
|
||||
###############################################################################
|
||||
# user config
|
||||
###############################################################################
|
||||
|
||||
USER dev
|
||||
WORKDIR /home/dev
|
||||
|
||||
RUN git clone --depth 1 https://github.com/wbthomason/packer.nvim \
|
||||
~/.local/share/nvim/site/pack/packer/start/packer.nvim
|
||||
|
||||
# clone dotfiles
|
||||
RUN sh -c "$(curl -fsLS get.chezmoi.io)"
|
||||
ENV PATH="/home/dev/bin:${PATH}"
|
||||
RUN chezmoi init --apply https://github.com/starr-dusT/dotfiles
|
||||
|
||||
CMD ["/bin/bash"]
|
22
resources/templates/dev_containers/dev.sh
Executable file
22
resources/templates/dev_containers/dev.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# https://github.com/starr-dusT/dotfiles
|
||||
|
||||
image_name="<image name>"
|
||||
container_name="<container name>"
|
||||
|
||||
# if container image doesn't exist build it
|
||||
if [ "$(docker images -q $image_name)" ]; then
|
||||
echo "Image exists don't need to build..."
|
||||
else
|
||||
docker run -t "$image_name" .
|
||||
fi
|
||||
|
||||
# if container doesn't exist run it else start/attach
|
||||
if [ "$(docker ps -a --filter "status=exited" --format "{{.Names}}" -f name=$container_name)" ]; then
|
||||
echo "Attaching to existing container..."
|
||||
docker start "$container_name"
|
||||
docker attach "$container_name"
|
||||
else
|
||||
echo "Running new container..."
|
||||
docker run --name "$container_name" --network host -v ./:/home/dev/src -it "$image_name"
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user