Skip to content

Commit 1a6b7a6

Browse files
committed
re-design docker development image
1 parent e629197 commit 1a6b7a6

File tree

6 files changed

+50
-43
lines changed

6 files changed

+50
-43
lines changed

docker/development/dockerfile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
FROM node:lts
1+
FROM fedora:latest
22

3-
# Arguments
4-
ARG OPENVSCODE_VERSION="1.74.0"
53
# Volumes
64
VOLUME /data
75

86
# Ports
97
# openvscode server port. Note: Runs HTTP by default
108
EXPOSE 3000
11-
# Dev Web Server port. Runs a self signed SSL certificate
12-
EXPOSE 443
139

1410
# System Environment Variables
1511
ENV PATH="/opt/vscode:${PATH}"
@@ -18,17 +14,17 @@ ENV SHELL="/bin/bash"
1814

1915
# User Set Environment Variables
2016
# Set to false if you do not want to attempt to pull a repository on first load
21-
ENV AUTOINITIALIZE=true
17+
ENV AUTOINITIALIZE=false
2218
# sets a connection token for VSCode Server. https://github.com/gitpod-io/openvscode-server#securing-access-to-your-ide
23-
ENV USE_CONNECTION_TOKEN=true
19+
ENV USE_CONNECTION_TOKEN=false
2420
#Set to a secret to have some measure of protection for vscode. Randomized if left blank
2521
ENV CONNECTION_TOKEN=
2622
# Project name. Typically the same as the project in the URL
2723
ENV PROJECT_NAME="headscale-ui"
2824
# URL for the github/git location
2925
ENV PROJECT_URL="https://github.com/gurucomputing/headscale-ui"
3026
# autostart the dev command on boot?
31-
ENV AUTOSTART=true
27+
ENV AUTOSTART="false"
3228
# command to run in the background on startup
3329
ENV DEV_COMMAND="npm run dev"
3430

@@ -49,8 +45,18 @@ RUN chmod -R 755 scripts
4945
RUN /staging/scripts/1-image-build.sh
5046

5147
# set to the non-root user
52-
USER node
48+
USER dev-user
5349

5450
WORKDIR /data
5551

56-
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh
52+
ENTRYPOINT /bin/sh /staging/scripts/2-initialise.sh#!/bin/sh
53+
54+
#----#
55+
# placeholder for testing
56+
# while true; do sleep 1; done
57+
#----#
58+
59+
# set file permissions if required
60+
if [ $(id -u) -ne $(stat -c %u /data) ]
61+
then
62+
…fi

docker/development/scripts/1-image-build.sh

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,22 @@
11
#!/bin/sh
22

33
# script environment
4-
# turn on bash logging
5-
set -x
4+
# turn on bash logging, exit on error
5+
set -ex
66

7-
# script variables
8-
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"
9-
OPENVSCODE_RELEASE="openvscode-server-v$OPENVSCODE_VERSION-linux-x64"
10-
CADDY_URL="https://caddyserver.com/api/download?os=linux&arch=amd64"
11-
12-
# install dependencies
13-
# tmux used for monitoring secondary processes
14-
# sudo for running specific commands as root
15-
apt-get update
16-
apt-get install -y tmux sudo
7+
# create a non-root user
8+
useradd -m -d /data/home dev-user
179

1810
# set the default shell to the chosen shell
19-
usermod --shell ${SHELL} node
11+
usermod --shell ${SHELL} dev-user
2012

2113
# Add the ability to set file permissions on /data to the non-privileged user
2214
echo "ALL ALL=NOPASSWD: /bin/chown -R 1000\:1000 /data" >> /etc/sudoers
2315

24-
# install openVSCode
25-
cd /opt
26-
27-
### Download Open VSCode
28-
curl -LJO "$OPENVSCODE_URL"
29-
30-
### Extract and move into directory
31-
tar -xzf "$OPENVSCODE_RELEASE.tar.gz"
32-
mv $OPENVSCODE_RELEASE openvscode-server
33-
rm -f "$OPENVSCODE_RELEASE.tar.gz"
34-
35-
### download caddy
36-
curl -LJO "$CADDY_URL"
37-
chmod +x caddy_linux_amd64
38-
mv caddy_linux_amd64 /usr/bin/caddy
39-
40-
# create data and home directories
41-
mkdir -p /data/home
16+
# install dependencies
17+
/staging/scripts/install-base-dependencies.sh
18+
/staging/scripts/install-container-dependencies.sh
19+
/staging/scripts/install-openvscode-server.sh
4220

4321
# set tmux to use mouse scroll
4422
echo "set -g mouse on" > /data/home/.tmux.conf

docker/development/scripts/2-initialise.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ then
1414
echo "---- Forcing File Permissions to the node user ----"
1515
sudo /bin/chown -R 1000:1000 /data
1616
else
17-
echo "---- You are not running as the node user AND your file permissions don't match your user ---\n"
17+
echo "---- You are not running as the default non-root user AND your file permissions don't match your user ---\n"
1818
echo "---- You may need to manually fix your file permissions ----"
1919
fi
2020
fi
@@ -40,7 +40,6 @@ then
4040
cd /data
4141
git clone ${PROJECT_URL}
4242
cd ${PROJECT_NAME}
43-
npm install
4443
else
4544
cd /data/${PROJECT_NAME}
4645
fi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# install dependencies
2+
# tmux used for monitoring secondary processes
3+
# sudo for running specific commands as root
4+
# git for source countrol
5+
# pwgen for creating randomized passwords/secrets on the fly
6+
# ncdu file navigation
7+
dnf install -y tmux sudo git pwgen ncdu
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# install container dependencies
2+
dnf module install -y nodejs
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# script variables
2+
OPENVSCODE_VERSION="1.79.2"
3+
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"
4+
OPENVSCODE_RELEASE="openvscode-server-v$OPENVSCODE_VERSION-linux-x64"
5+
6+
# install openVSCode
7+
cd /opt
8+
9+
### Download Open VSCode
10+
curl -LJO "$OPENVSCODE_URL"
11+
12+
### Extract and move into directory
13+
tar -xzf "$OPENVSCODE_RELEASE.tar.gz"
14+
mv $OPENVSCODE_RELEASE openvscode-server
15+
rm -f "$OPENVSCODE_RELEASE.tar.gz"

0 commit comments

Comments
 (0)