Working Dockerfiles for Fedora and Ubuntu, changes to settings and project-creator
This commit is contained in:
parent
472f9f3a68
commit
e63cf2a777
@ -9,10 +9,10 @@ RUN dnf update -y && dnf install -y \
|
||||
htop \
|
||||
vim \
|
||||
nano \
|
||||
dumb-init \
|
||||
tar \
|
||||
bzip2 \
|
||||
unzip \
|
||||
python3-pip \
|
||||
&& rm -rf /var/cache/dnf \
|
||||
&& git lfs install \
|
||||
&& curl -fsSL https://code-server.dev/install.sh | sh
|
||||
@ -54,15 +54,21 @@ RUN curl -fsSL ${WPILIB_DL_URL} -o /tmp/${WPILIB_FILE_NAME} \
|
||||
&& echo "export PATH=$PATH:/home/coder/wpilib/$ARTIFACTSYEAR/jdk/bin" >> "/home/coder/.bashrc.d/wpilib.sh" \
|
||||
&& echo "export PATH=$PATH:$GRADLEFOLDER/bin" >> "/home/coder/.bashrc.d/wpilib.sh" \
|
||||
&& source /home/coder/.bashrc.d/wpilib.sh \
|
||||
&& su -c "/home/coder/wpilib/$ARTIFACTSYEAR/jdk/bin/java -jar /home/coder/wpilib/$ARTIFACTSYEAR/tools/ToolsUpdater.jar" "coder" \
|
||||
# && su -c "/home/coder/wpilib/$ARTIFACTSYEAR/jdk/bin/java -jar /home/coder/wpilib/$ARTIFACTSYEAR/tools/ToolsUpdater.jar" "coder" \
|
||||
&& su -c "/home/coder/wpilib/$ARTIFACTSYEAR/jdk/bin/java -jar /home/coder/wpilib/$ARTIFACTSYEAR/maven/MavenMetaDataFixer.jar" "coder" \
|
||||
&& rm -rf /home/coder/wpilib/$ARTIFACTSYEAR/advantagescope \
|
||||
&& rm -f /home/coder/wpilib/$ARTIFACTSYEAR/installUtils/$GRADLEZIP \
|
||||
&& rm -rf /home/coder/wpilib/$ARTIFACTSYEAR/tools \
|
||||
&& rm -rf /root/.cache \
|
||||
&& su -c "mkdir -p /home/coder/.local/share" "coder" \
|
||||
&& su -c "mkdir -p /home/coder/.config/code-server" "coder" \
|
||||
&& su -c "tar -xzf /tmp/code-server.tar.gz -C /home/coder/.local/share" "coder" \
|
||||
&& su -c "cp -f /tmp/settings.json /home/coder/.local/share/code-server/User" "coder" \
|
||||
&& su -c "sed -i 's/###YEAR###/$ARTIFACTSYEAR/g;' /home/coder/.local/share/code-server/User/settings.json" "coder" \
|
||||
&& su -c "cp -f /tmp/config.yaml /home/coder/.config/code-server" "coder" \
|
||||
&& NEW_PASS="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20; echo)" \
|
||||
&& su -c "sed -i 's/PASSWORD/$NEW_PASS/g;' /home/coder/.config/code-server/config.yaml" "coder" \
|
||||
&& su -c "sed -i 's/PASSWORD/$NEW_PASS/g;' /home/coder/.config/code-server/config.yaml" "coder"\
|
||||
&& su -c "cp -f /tmp/project-creator.py /home/coder" "coder" \
|
||||
&& for EXTENSION in /home/coder/wpilib/$ARTIFACTSYEAR/vsCodeExtensions/*.vsix; do su -c "code-server --install-extension $EXTENSION" "coder"; done
|
||||
|
||||
EXPOSE 8080
|
82
Dockerfile.ubuntu
Normal file
82
Dockerfile.ubuntu
Normal file
@ -0,0 +1,82 @@
|
||||
# syntax=docker/dockerfile:experimental
|
||||
|
||||
FROM ubuntu:24.04
|
||||
|
||||
RUN apt update -y && apt upgrade -y \
|
||||
curl \
|
||||
git \
|
||||
git-lfs \
|
||||
htop \
|
||||
vim \
|
||||
nano \
|
||||
tar \
|
||||
bzip2 \
|
||||
unzip \
|
||||
python3-pip \
|
||||
&& apt clean \
|
||||
&& git lfs install \
|
||||
&& curl -fsSL https://code-server.dev/install.sh | sh
|
||||
|
||||
RUN mkdir -p /etc/sudoers.d
|
||||
RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
|
||||
|
||||
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g')" \
|
||||
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
|
||||
&& chown root:root /usr/local/bin/fixuid \
|
||||
&& chmod 4755 /usr/local/bin/fixuid \
|
||||
&& mkdir -p /etc/fixuid \
|
||||
&& printf "user: ubuntu\ngroup: ubuntu\n" > /etc/fixuid/config.yml
|
||||
|
||||
COPY code-server.tar.gz /tmp
|
||||
COPY settings.json /tmp
|
||||
COPY config.yaml /tmp
|
||||
COPY project-creator.py /tmp
|
||||
|
||||
ARG WPILIB_DL_URL
|
||||
ARG WPILIB_FILE_NAME=wpilib.tar.gz
|
||||
|
||||
RUN curl -fsSL ${WPILIB_DL_URL} -o /tmp/${WPILIB_FILE_NAME} \
|
||||
&& tar -xzf "/tmp/${WPILIB_FILE_NAME}" -C /tmp \
|
||||
&& WPILIB_ARTIFACTS="$(find /tmp -type f -name 'WPILib_Linux-*-artifacts.tar.gz' -print)" \
|
||||
&& ARTIFACTSYEAR="$(echo $WPILIB_ARTIFACTS | cut -d '-' -f 2 | cut -d '.' -f 1)" \
|
||||
&& mkdir -p /home/ubuntu/wpilib/$ARTIFACTSYEAR \
|
||||
&& tar -xzf "$WPILIB_ARTIFACTS" -C /home/ubuntu/wpilib/$ARTIFACTSYEAR \
|
||||
&& chown -R ubuntu:ubuntu /home/ubuntu/wpilib \
|
||||
&& rm -f /tmp/${WPILIB_FILE_NAME} \
|
||||
&& rm -rf "$(find /tmp -type d -name 'WPILib_Linux-*' -print)" \
|
||||
&& GRADLEZIP="$(ls /home/ubuntu/wpilib/$ARTIFACTSYEAR/installUtils | grep 'gradle-.*-bin.zip')" \
|
||||
&& GRADLEFOLDER="/home/ubuntu/gradle-$(echo \"$GRADLEZIP\" | cut -d '-' -f 2)" \
|
||||
&& unzip /home/ubuntu/wpilib/$ARTIFACTSYEAR/installUtils/$GRADLEZIP -d /home/ubuntu/ \
|
||||
&& chown -R ubuntu:ubuntu $GRADLEFOLDER \
|
||||
&& mkdir /home/ubuntu/.bashrc.d \
|
||||
&& touch /home/ubuntu/.bashrc.d/wpilib.sh \
|
||||
&& chown -R ubuntu:ubuntu /home/ubuntu/.bashrc.d \
|
||||
&& echo "export JAVA_HOME=/home/ubuntu/wpilib/$ARTIFACTSYEAR/jdk" >> "/home/ubuntu/.bashrc.d/wpilib.sh" \
|
||||
&& echo "export PATH=$PATH:/home/ubuntu/wpilib/$ARTIFACTSYEAR/jdk/bin" >> "/home/ubuntu/.bashrc.d/wpilib.sh" \
|
||||
&& echo "export PATH=$PATH:$GRADLEFOLDER/bin" >> "/home/ubuntu/.bashrc.d/wpilib.sh" \
|
||||
&& . /home/ubuntu/.bashrc.d/wpilib.sh \
|
||||
# && su -c "/home/ubuntu/wpilib/$ARTIFACTSYEAR/jdk/bin/java -jar /home/ubuntu/wpilib/$ARTIFACTSYEAR/tools/ToolsUpdater.jar" "ubuntu" \
|
||||
&& su -c "/home/ubuntu/wpilib/$ARTIFACTSYEAR/jdk/bin/java -jar /home/ubuntu/wpilib/$ARTIFACTSYEAR/maven/MavenMetaDataFixer.jar" "ubuntu" \
|
||||
&& rm -rf /home/ubuntu/wpilib/$ARTIFACTSYEAR/advantagescope \
|
||||
&& rm -f /home/ubuntu/wpilib/$ARTIFACTSYEAR/installUtils/$GRADLEZIP \
|
||||
&& rm -rf /home/ubuntu/wpilib/$ARTIFACTSYEAR/tools \
|
||||
&& rm -rf /root/.cache \
|
||||
&& su -c "mkdir -p /home/ubuntu/.local/share" "ubuntu" \
|
||||
&& su -c "mkdir -p /home/ubuntu/.config/code-server" "ubuntu" \
|
||||
&& su -c "tar -xzf /tmp/code-server.tar.gz -C /home/ubuntu/.local/share" "ubuntu" \
|
||||
&& su -c "cp -f /tmp/settings.json /home/ubuntu/.local/share/code-server/User" "ubuntu" \
|
||||
&& su -c "sed -i 's/###YEAR###/$ARTIFACTSYEAR/g;s/coder/ubuntu/g;' /home/ubuntu/.local/share/code-server/User/settings.json" "ubuntu" \
|
||||
&& su -c "cp -f /tmp/config.yaml /home/ubuntu/.config/code-server" "ubuntu" \
|
||||
&& NEW_PASS="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20; echo)" \
|
||||
&& su -c "sed -i 's/PASSWORD/$NEW_PASS/g;' /home/ubuntu/.config/code-server/config.yaml" "ubuntu"\
|
||||
&& su -c "cp -f /tmp/project-creator.py /home/ubuntu" "ubuntu" \
|
||||
&& for EXTENSION in /home/ubuntu/wpilib/$ARTIFACTSYEAR/vsCodeExtensions/*.vsix; do su -c "code-server --install-extension $EXTENSION" "ubuntu"; done
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
USER ubuntu
|
||||
ENV USER=ubuntu
|
||||
WORKDIR /home/ubuntu
|
||||
ENTRYPOINT ["/usr/bin/code-server", "--bind-addr", "0.0.0.0:8080", "."]
|
||||
|
||||
|
@ -22,13 +22,6 @@ def show_options(option_list, columns):
|
||||
|
||||
print("")
|
||||
|
||||
#def show_options(option_list, columns):
|
||||
# for x in range(0, len(option_list), columns):
|
||||
# for y in range(x, min(len(option_list), x + columns), 1):
|
||||
# print("[{opnum}] {option}".format(opnum=y, option=option_list[y]), end=' ')
|
||||
#
|
||||
# print("")
|
||||
|
||||
def get_selection(option_list, columns, prompt):
|
||||
selection = ""
|
||||
|
||||
@ -158,7 +151,17 @@ shutil.copytree(vendordeps, os.path.join(new_project_path, "vendordeps"), dirs_e
|
||||
|
||||
### END Generate project directories and fill them with the appropriate files
|
||||
|
||||
### BEGIN Do find and replace work for java projects and all projects team number config
|
||||
### BEGIN Do find and replace work for java and cpp projects and all projects team number config
|
||||
|
||||
### TODO Opening and closing build.gradle is unnecessarily repetitive,
|
||||
### Might be better to lose the with calls and manually open/close the files?
|
||||
with open(os.path.join(new_project_path, "build.gradle"), "r") as gradle_build_file:
|
||||
gradle_build_content = gradle_build_file.read()
|
||||
|
||||
gradle_build_content = gradle_build_content.replace("###GRADLERIOREPLACE###", wpilib_version)
|
||||
|
||||
with open(os.path.join(new_project_path, "build.gradle"), "w") as gradle_build_file:
|
||||
gradle_build_file.write(gradle_build_content)
|
||||
|
||||
if project_language == "java":
|
||||
|
||||
@ -167,7 +170,6 @@ if project_language == "java":
|
||||
with open(os.path.join(new_project_path, "build.gradle"), "r") as gradle_build_file:
|
||||
gradle_build_content = gradle_build_file.read()
|
||||
|
||||
gradle_build_content = gradle_build_content.replace("###GRADLERIOREPLACE###", wpilib_version)
|
||||
gradle_build_content = gradle_build_content.replace("###ROBOTCLASSREPLACE###", "frc.robot.Main")
|
||||
|
||||
with open(os.path.join(new_project_path, "build.gradle"), "w") as gradle_build_file:
|
||||
@ -175,7 +177,7 @@ if project_language == "java":
|
||||
|
||||
### END Gradle build file changes for Java
|
||||
|
||||
### BEGIN *.java find and replace template package in all files
|
||||
### BEGIN *.java find and replace template/example package in all files
|
||||
# This regular expression trickery needs to be HEAVILY tested.
|
||||
# I don't think it's going to hold up everywhere...
|
||||
|
||||
@ -185,7 +187,7 @@ if project_language == "java":
|
||||
# Note that because the last [option]* list doesn't include period, this
|
||||
# SHOULD ignore any continuing package structures after what we want to replace,
|
||||
# this is necessary as to not break command based templates
|
||||
template_regex = re.compile(r'edu\.wpi\.first\.wpilibj\.templates\.[a-zA-Z0-9]*')
|
||||
template_regex = re.compile(r'edu\.wpi\.first\.wpilibj\.(templates|examples)\.[a-zA-Z0-9]*')
|
||||
|
||||
for file in glob.glob(os.path.join(new_project_path_src, "**", "*.java"), recursive=True):
|
||||
with open(file, "r") as java_file:
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"workbench.colorTheme": "Visual Studio Dark",
|
||||
"java.jdt.ls.java.home": "/home/bradley/wpilib/2023/jdk",
|
||||
"java.jdt.ls.java.home": "/home/coder/wpilib/###YEAR###/jdk",
|
||||
"extensions.autoUpdate": false,
|
||||
"extensions.autoCheckUpdates": false,
|
||||
"extensions.ignoreRecommendations": true,
|
||||
|
Loading…
Reference in New Issue
Block a user