re-design docker development image

This commit is contained in:
Christopher Bisset 2023-06-18 17:18:40 +10:00
parent e629197b36
commit 1a6b7a6626
6 changed files with 50 additions and 43 deletions

View file

@ -1,15 +1,11 @@
FROM node:lts
FROM fedora:latest
# Arguments
ARG OPENVSCODE_VERSION="1.74.0"
# Volumes
VOLUME /data
# Ports
# openvscode server port. Note: Runs HTTP by default
EXPOSE 3000
# Dev Web Server port. Runs a self signed SSL certificate
EXPOSE 443
# System Environment Variables
ENV PATH="/opt/vscode:${PATH}"
@ -18,9 +14,9 @@ ENV SHELL="/bin/bash"
# User Set Environment Variables
# Set to false if you do not want to attempt to pull a repository on first load
ENV AUTOINITIALIZE=true
ENV AUTOINITIALIZE=false
# sets a connection token for VSCode Server. https://github.com/gitpod-io/openvscode-server#securing-access-to-your-ide
ENV USE_CONNECTION_TOKEN=true
ENV USE_CONNECTION_TOKEN=false
#Set to a secret to have some measure of protection for vscode. Randomized if left blank
ENV CONNECTION_TOKEN=
# Project name. Typically the same as the project in the URL
@ -28,7 +24,7 @@ ENV PROJECT_NAME="headscale-ui"
# URL for the github/git location
ENV PROJECT_URL="https://github.com/gurucomputing/headscale-ui"
# autostart the dev command on boot?
ENV AUTOSTART=true
ENV AUTOSTART="false"
# command to run in the background on startup
ENV DEV_COMMAND="npm run dev"
@ -49,8 +45,18 @@ RUN chmod -R 755 scripts
RUN /staging/scripts/1-image-build.sh
# set to the non-root user
USER node
USER dev-user
WORKDIR /data
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh#!/bin/sh
#----#
# placeholder for testing
# while true; do sleep 1; done
#----#
# set file permissions if required
if [ $(id -u) -ne $(stat -c %u /data) ]
then
…fi

View file

@ -1,44 +1,22 @@
#!/bin/sh
# script environment
# turn on bash logging
set -x
# turn on bash logging, exit on error
set -ex
# script variables
OPENVSCODE_URL="https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v$OPENVSCODE_VERSION/openvscode-server-v$OPENVSCODE_VERSION-linux-x64.tar.gz"
OPENVSCODE_RELEASE="openvscode-server-v$OPENVSCODE_VERSION-linux-x64"
CADDY_URL="https://caddyserver.com/api/download?os=linux&arch=amd64"
# install dependencies
# tmux used for monitoring secondary processes
# sudo for running specific commands as root
apt-get update
apt-get install -y tmux sudo
# create a non-root user
useradd -m -d /data/home dev-user
# set the default shell to the chosen shell
usermod --shell ${SHELL} node
usermod --shell ${SHELL} dev-user
# Add the ability to set file permissions on /data to the non-privileged user
echo "ALL ALL=NOPASSWD: /bin/chown -R 1000\:1000 /data" >> /etc/sudoers
# install openVSCode
cd /opt
### Download Open VSCode
curl -LJO "$OPENVSCODE_URL"
### Extract and move into directory
tar -xzf "$OPENVSCODE_RELEASE.tar.gz"
mv $OPENVSCODE_RELEASE openvscode-server
rm -f "$OPENVSCODE_RELEASE.tar.gz"
### download caddy
curl -LJO "$CADDY_URL"
chmod +x caddy_linux_amd64
mv caddy_linux_amd64 /usr/bin/caddy
# create data and home directories
mkdir -p /data/home
# install dependencies
/staging/scripts/install-base-dependencies.sh
/staging/scripts/install-container-dependencies.sh
/staging/scripts/install-openvscode-server.sh
# set tmux to use mouse scroll
echo "set -g mouse on" > /data/home/.tmux.conf

View file

@ -14,7 +14,7 @@ then
echo "---- Forcing File Permissions to the node user ----"
sudo /bin/chown -R 1000:1000 /data
else
echo "---- You are not running as the node user AND your file permissions don't match your user ---\n"
echo "---- You are not running as the default non-root user AND your file permissions don't match your user ---\n"
echo "---- You may need to manually fix your file permissions ----"
fi
fi
@ -40,7 +40,6 @@ then
cd /data
git clone ${PROJECT_URL}
cd ${PROJECT_NAME}
npm install
else
cd /data/${PROJECT_NAME}
fi

View file

@ -0,0 +1,7 @@
# install dependencies
# tmux used for monitoring secondary processes
# sudo for running specific commands as root
# git for source countrol
# pwgen for creating randomized passwords/secrets on the fly
# ncdu file navigation
dnf install -y tmux sudo git pwgen ncdu

View file

@ -0,0 +1,2 @@
# install container dependencies
dnf module install -y nodejs

View file

@ -0,0 +1,15 @@
# script variables
OPENVSCODE_VERSION="1.79.2"
OPENVSCODE_URL="https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v$OPENVSCODE_VERSION/openvscode-server-v$OPENVSCODE_VERSION-linux-x64.tar.gz"
OPENVSCODE_RELEASE="openvscode-server-v$OPENVSCODE_VERSION-linux-x64"
# install openVSCode
cd /opt
### Download Open VSCode
curl -LJO "$OPENVSCODE_URL"
### Extract and move into directory
tar -xzf "$OPENVSCODE_RELEASE.tar.gz"
mv $OPENVSCODE_RELEASE openvscode-server
rm -f "$OPENVSCODE_RELEASE.tar.gz"