-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
197 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
GIT_BRANCH_COLOR_CLEAN=$(tput setaf 2) | ||
GIT_BRANCH_COLOR_DIRTY=$(tput setaf 1) | ||
BOLD=$(tput bold) | ||
NORM=$(tput sgr0) | ||
NO_COLOR=$(tput sgr0) | ||
|
||
parse_git_branch() | ||
{ | ||
branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/') | ||
|
||
if [[ -n $branch ]] | ||
then | ||
if [ -n "$(git status --untracked-files=no --porcelain)" ] | ||
then | ||
# Uncommitted changes | ||
branch+='*' | ||
echo "${GIT_BRANCH_COLOR_DIRTY}${BOLD}${branch}${NORM}${NO_COLOR}" | ||
else | ||
echo "${GIT_BRANCH_COLOR_CLEAN}${branch}${NO_COLOR}" | ||
fi | ||
fi | ||
} | ||
|
||
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]\[\033[01;34m\] \w\[\$(parse_git_branch)\]\[\e[00m\]\n> " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,73 @@ | ||
FROM ubuntu:23.04 | ||
FROM ubuntu:24.04 | ||
|
||
ARG ENV_FILE=/home/ubuntu/.env_setup | ||
ARG project_dir=/home/ubuntu/project | ||
ARG ruby_version=3.1.4 | ||
ARG node_version=16.13.2 | ||
|
||
ENV RUBY_VERSION=${ruby_version} | ||
ENV NODE_VERSION=${node_version} | ||
|
||
RUN \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
curl \ | ||
git \ | ||
ca-certificates \ | ||
ruby-full \ | ||
build-essential \ | ||
openssh-client \ | ||
sudo \ | ||
zlib1g-dev | ||
|
||
# Disable password prompt for sudo commands | ||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
USER ubuntu | ||
WORKDIR /home/ubuntu | ||
WORKDIR ${project_dir} | ||
|
||
RUN \ | ||
curl -sSL https://get.rvm.io | bash -s stable && \ | ||
/home/ubuntu/.rvm/bin/rvm install ${ruby_version} && \ | ||
/home/ubuntu/.rvm/bin/rvm use ${ruby_version} | ||
|
||
RUN \ | ||
echo "#!/bin/bash" >> $ENV_FILE && \ | ||
echo "export GEM_HOME=/home/ubuntu/gems" >> $ENV_FILE && \ | ||
echo "export GEM_PATH=/home/ubuntu/gems" >> $ENV_FILE && \ | ||
echo "export NVM_DIR=/home/ubuntu/.nvm" >> $ENV_FILE && \ | ||
echo "export PATH=\"/home/ubuntu/gems/bin:$PATH\"" >> $ENV_FILE && \ | ||
echo '[ -s $NVM_DIR/nvm.sh ] && \. $NVM_DIR/nvm.sh || true' >> $ENV_FILE | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash | ||
|
||
COPY \ | ||
.devcontainer/.git_branch_bash \ | ||
/home/ubuntu | ||
|
||
# Temporarily add Makefile, Gemfile and NPM package files so that installation is done during | ||
# the container build phase. | ||
ADD \ | ||
|
||
RUN mkdir ${project_dir}/scripts | ||
|
||
COPY \ | ||
Makefile \ | ||
Gemfile \ | ||
Gemfile.lock \ | ||
package.json \ | ||
package-lock.json \ | ||
/home/ubuntu | ||
${project_dir} | ||
|
||
COPY \ | ||
scripts/env_setup.sh \ | ||
${project_dir}/scripts | ||
|
||
RUN \ | ||
sudo chown ubuntu:ubuntu \ | ||
/home/ubuntu/package.json \ | ||
/home/ubuntu/package-lock.json \ | ||
&& \ | ||
sudo chmod 666 package-lock.json && \ | ||
make install && \ | ||
rm \ | ||
/home/ubuntu/Makefile \ | ||
/home/ubuntu/Gemfile \ | ||
/home/ubuntu/Gemfile.lock \ | ||
/home/ubuntu/package.json \ | ||
/home/ubuntu/package-lock.json | ||
rm Makefile \ | ||
Gemfile \ | ||
Gemfile.lock \ | ||
package.json \ | ||
package-lock.json && \ | ||
rm -rf ${project_dir}/scripts | ||
|
||
RUN \ | ||
tee -a /home/ubuntu/.bashrc <<EOF | ||
alias mkc='make clean' | ||
source /home/ubuntu/.git_branch_bash | ||
source /usr/share/bash-completion/completions/git | ||
EOF | ||
|
||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
{ | ||
"name": "Shantea Controls Website", | ||
"dockerComposeFile": [ | ||
"../docker-compose-build.yml" | ||
], | ||
"service": "shanteacontrols-website", | ||
"workspaceFolder": "/home/ubuntu/website", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"llvm-vs-code-extensions.vscode-clangd", | ||
"eamodio.gitlens", | ||
"xaver.clang-format", | ||
"timonwong.shellcheck" | ||
] | ||
} | ||
} | ||
"name": "${localWorkspaceFolderBasename}", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "${localWorkspaceFolder}" | ||
}, | ||
"workspaceMount": "src=${localWorkspaceFolder},dst=/home/ubuntu/project,type=bind", | ||
"workspaceFolder": "/home/ubuntu/project", | ||
"mounts": [ | ||
{ | ||
"source": "${localEnv:HOME}/.gitconfig", | ||
"target": "/etc/gitconfig", | ||
"type": "bind" | ||
}, | ||
{ | ||
"source": "${localEnv:HOME}/.ssh", | ||
"target": "/home/ubuntu/.ssh", | ||
"type": "bind" | ||
} | ||
], | ||
"runArgs": [ | ||
"--network=host", | ||
"--hostname=${localWorkspaceFolderBasename}", | ||
], | ||
"containerUser": "ubuntu", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"llvm-vs-code-extensions.vscode-clangd", | ||
"eamodio.gitlens", | ||
"xaver.clang-format", | ||
"timonwong.shellcheck" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,40 @@ on: | |
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: paradajz168/website-dev:latest | ||
options: --user root | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Mark repository as safe | ||
run: git config --global --add safe.directory /__w/website/website | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Pull the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Deploy | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Setup missing directories and files on the runner | ||
run: | | ||
git config --global user.name "web_bot" | ||
git config --global user.email "[email protected]" | ||
make prod | ||
git checkout gh-pages | ||
cp -R _site/deploy/* . | ||
git add . | ||
git commit --allow-empty -m "update" | ||
git push https://github.com/shanteacontrols/website gh-pages | ||
mkdir -p ~/.ssh | ||
touch ~/.gitconfig | ||
- name: Prepare container | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: website # Local name only | ||
imageTag: latest # Local tag only | ||
push: never | ||
- name: Deploy | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: website | ||
imageTag: latest | ||
push: never | ||
runCmd: | | ||
git config --global user.name "web_bot" | ||
git config --global user.email "[email protected]" | ||
make prod | ||
git checkout gh-pages | ||
cp -R _site/deploy/* . | ||
git add . | ||
git commit --allow-empty -m "update" | ||
git push https://github.com/shanteacontrols/website gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) | ||
project_root="$(realpath "${script_dir}"/..)" | ||
|
||
export GEM_HOME=$project_root/gems | ||
export GEM_PATH=$project_root/gems | ||
export PATH="$project_root/gems/bin:$PATH" | ||
export NVM_DIR="$HOME/.nvm" | ||
|
||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
source ~/.rvm/scripts/rvm | ||
rvm use "$RUBY_VERSION" |