Skip to content

Commit

Permalink
feat: Optimized CCC a lot
Browse files Browse the repository at this point in the history
Refactored it to be part of the main tools package and not in a separate package to utilize models and dependencies of the main tools package.

Restructured the code to be better readable and understandable.

Deprecations are now visible in the CCC terminal.
  • Loading branch information
dploeger committed Oct 11, 2024
1 parent 30348e9 commit 55ae0da
Show file tree
Hide file tree
Showing 21 changed files with 746 additions and 667 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.23

- name: Update README
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.23
- name: Setup Docker buildx
uses: docker/[email protected]
- name: Set up QEMU
Expand Down
19 changes: 17 additions & 2 deletions assets/cloudcontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ TERM=xterm
if [ "X$1X" == "XserveX" ]
then
cd /usr/local/ccc || exit 1
./ccc 2>&1
if [ -z "${DEBUG_CCC}" ]
then
export GIN_MODE=release
./ccc 2>&1
else
./ccc --loglevel debug 2>&1
fi
elif [ "X$1X" == "XrunX" ]
then
if [ "X${MOTD}X" != "XX" ]
Expand All @@ -21,12 +27,21 @@ then
then
echo
echo
curl -H "Accept: text/plain" -s http://localhost:8080/api/features
curl -H "Accept: text/plain" -s http://localhost:8080/api/features | markdown
echo
fi

echo

if [ -r /home/cloudcontrol/.deprecation ];
then
echo "# ⚠️ Deprecation" | markdown
echo
echo "The following deprecations were found:"
echo "---" | markdown
markdown < /home/cloudcontrol/.deprecation
fi

export PATH=$PATH:/home/cloudcontrol/bin

if [ -n "${WORKDIR}" ]
Expand Down
7 changes: 7 additions & 0 deletions assets/feature-installer-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,10 @@ function downloadFromGithub {

execHandle "Downloading ${USER}/${REPO}@${VERSION}" curl -f -s -L "https://github.com/${USER}/${REPO}/releases/download/${VERSION}/${PACKAGE}" --output "${TARGET}"
}

# Usage: deprecate PART HINT
#
# Logs that a certain PART of CloudControl is deprecated, so that the HINT about it can be shown to the user when they log in
function deprecate {
echo -e "${1}\n\n${2}\n\n---" >> /home/cloudcontrol/.deprecation
}
14 changes: 8 additions & 6 deletions build/Dockerfile.prefix
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM node:lts-slim as cccClientBuild
FROM node:lts-slim AS ccc-client-build

WORKDIR /build
COPY ccc-client /build
RUN npm config set update-notifier false
RUN npm install
RUN npm run-script build -- --base=/client/

FROM golang:1.19 AS cccBuild
FROM golang:1.23 AS go-build

WORKDIR /build
COPY ccc/go.mod /build
COPY ccc/go.sum /build
COPY ccc/ccc.go /build
RUN go build ccc.go
COPY go.mod /build
COPY go.sum /build
COPY cmd /build/cmd
COPY internal /build/internal
RUN go build cmd/ccc/ccc.go
RUN go build cmd/markdown/markdown.go
9 changes: 7 additions & 2 deletions build/Dockerfile.suffix.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ COPY assets/feature-installer-utils.sh /

# CCC

COPY --from=cccBuild /build/ccc /usr/local/ccc/ccc
COPY --from=go-build /build/ccc /usr/local/ccc/ccc
RUN chmod +x /usr/local/ccc/ccc

COPY --from=cccClientBuild /build/dist /usr/local/ccc/client
COPY --from=ccc-client-build /build/dist /usr/local/ccc/client

# Cloud control

COPY assets/cloudcontrol.sh /usr/local/bin/cloudcontrol
RUN chmod +x /usr/local/bin/cloudcontrol

# Markdown

COPY --from=go-build /build/markdown /home/cloudcontrol/bin/markdown
RUN chmod +x /home/cloudcontrol/bin/markdown

# Chown

RUN chown cloudcontrol -R /home/cloudcontrol
Expand Down
Loading

0 comments on commit 55ae0da

Please sign in to comment.