Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/build
/od-ash-tray
/ash-tray
.env
/cdn/*
test*

5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /od-ash-tray .
FROM scratch
COPY --from=build /od-ash-tray /od-ash-tray

# bandaid fix
# we'll have to fix this later...
COPY ./fullchain.pem fullchain.pem
COPY ./privkey.pem privkey.pem
COPY ./ash.yaml ./ash.yaml
CMD ["/od-ash-tray"]
43 changes: 10 additions & 33 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ pipeline {
}

stages {
stage('Certs Copy (ISSUE)') {
steps {
sh 'cp /etc/letsencrypt/archive/onlinedi.vision/fullchain2.pem fullchain.pem'
sh 'cp /etc/letsencrypt/archive/onlinedi.vision/privkey2.pem privkey.pem'
sh 'touch ash.yaml'
}
}
stage('DEL_CDN Setup') {
steps {
sh 'stat ~/del_cdn 2> /dev/null > /dev/null || mkdir ~/del_cdn'
Expand All @@ -39,31 +32,24 @@ pipeline {
stage('First Shadow') {
steps{
sh 'file_sufix=$(curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@shadows/1.png" -k https://127.0.0.1:7377/upload | tail -n1); \
echo "${file_sufix}"; \
curl "https://127.0.0.1:7377/${file_sufix}" -k -o test1 ;\
count=$(wc -l shadows/1.png | cut -f1 -d" "); \
diffr=$(sdiff -B -b -s test1 shadows/1.png | wc -l); \
exit $(( $diffr*100/$count )); \
diff test1 shadows/1.png \
'
}
}
stage('Second Shadow') {
steps{
sh 'file_sufix=$(curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@shadows/2.png" -k https://127.0.0.1:7377/upload | tail -n1); \
curl -k "https://127.0.0.1:7377/${file_sufix}" -o test2; \
count=$(wc -l shadows/2.png | cut -f1 -d" "); \
diffr=$(sdiff -B -b -s test2 shadows/2.png | wc -l); \
exit $(( $diffr*100/$count )); \
diff test2 shadows/2.png \
'
}
}
stage('Third Shadow') {
steps {
sh 'file_sufix=$(curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@shadows/3.png" -k https://127.0.0.1:7377/upload | tail -n1); \
curl -k "https://127.0.0.1:7377/${file_sufix}" -o test3; \
count=$(wc -l shadows/3.png | cut -f1 -d" "); \
diffr=$(sdiff -B -b -s test3 shadows/3.png | wc -l); \
exit $(( $diffr*100/$count )); \
diff test3 shadows/3.png \
'
}
}
Expand All @@ -72,9 +58,7 @@ pipeline {
steps {
sh 'file_sufix=$(curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@shadows/4.png" -k https://127.0.0.1:7377/upload | tail -n1); \
curl -k "https://127.0.0.1:7377/${file_sufix}" -o test4; \
count=$(wc -l shadows/4.png | cut -f1 -d" "); \
diffr=$(sdiff -B -b -s test4 shadows/4.png | wc -l); \
exit $(( $diffr*100/$count )); \
diff test4 shadows/4.png \
'
}
}
Expand All @@ -83,20 +67,18 @@ pipeline {
steps {
sh 'file_sufix=$(curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@shadows/5.png" -k https://127.0.0.1:7377/upload | tail -n1); \
curl -k "https://127.0.0.1:7377/${file_sufix}" -o test5; \
count=$(wc -l shadows/5.png | cut -f1 -d" "); \
diffr=$(sdiff -B -b -s test5 shadows/5.png | wc -l); \
exit $(( $diffr*100/$count )); \
diff test5 shadows/5.png \
'
}
}
}
}

// stage('Cleanup Shadow Arena') {
// steps {
// sh 'rm -rf ~/del_cdn'
// }
// }
stage('Cleanup Shadow Arena') {
steps {
sh 'rm -rf ~/del_cdn'
}
}

stage('Docker Kill') {
steps {
Expand All @@ -116,10 +98,5 @@ pipeline {
}
}
}
stage('Certs Cleanup') {
steps {
sh 'rm privkey.pem fullchain.pem'
}
}
}
}
5 changes: 0 additions & 5 deletions ci-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@ WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /od-ash-tray .

FROM scratch
COPY --from=build /od-ash-tray /od-ash-tray

# bandaid fix
# we'll have to fix this later...
CMD ["/od-ash-tray"]
8 changes: 3 additions & 5 deletions ci-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ services:
ports:
- "0.0.0.0:7377:7377"
environment:
- ASH_TRAY_ID
- ASH_TRAY_ID=ash
- ASH_TRAY_DIRECTORY=/cdn
- ASH_TRAY_KEY
- ASH_TRAY_KEY=aaaaaVVVVVVVAAAAAAAAaaaaaaaaaaaa
- ASH_TRAY_PORT=7377
volumes:
- /cdn:/cdn:rw
- /etc/letsencrypt/live/onlinedi.vision:/certs:r

- ./cdn:/cdn:rw
4 changes: 1 addition & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ services:
od-ash_tray:
build: .
ports:
- "0.0.0.0:7377:7377"
- "127.0.0.1:7377:7377"
environment:
- ASH_TRAY_ID
- ASH_TRAY_DIRECTORY=/cdn
- ASH_TRAY_KEY
- ASH_TRAY_PORT=7377
volumes:
- /cdn:/cdn:rw
- /etc/letsencrypt/live/onlinedi.vision:/certs:r

67 changes: 67 additions & 0 deletions launch-test-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -eu

COMPOSE_FLAGS=(-f ci-compose.yaml)
ASH_HOST="http://127.0.0.1:7377"

function print_usage() {
echo "Usage: ./launch-test-env.sh [OPTION]"
echo "OPTION:"
echo " -c clean the environment (stop processes / kill docker) "
echo " -W complete wipeout of the environment"
echo " -t run tests..."
echo " -b skip rebuild"
}


function cleanup() {
echo "========= CLEANING UP COMPOSE ==========="
docker compose "${COMPOSE_FLAGS[@]}" down
}

function wipeout() {
echo "========= COMPLETE WIPEOUT OF ENV ==========="
docker compose "${COMPOSE_FLAGS[@]}" down --rmi 'all'
sudo rm -rf cdn
rm -rf test*
}

trap 'cleanup' SIGINT SIGTERM

t_flag=''
b_flag=''
while getopts 'htcWb' flag; do
case "${flag}" in
b) b_flag='true';;
t) t_flag='true';;
c) cleanup
exit 0;;
W) wipeout
exit 0;;
h) print_usage
exit 0 ;;
*) print_usage
exit 1 ;;
esac
done

echo "========= BUILDING PROJECT ==========="
if ! [[ "${b_flag}" == "true" ]]; then
docker compose "${COMPOSE_FLAGS[@]}" build --no-cache
fi
docker compose "${COMPOSE_FLAGS[@]}" up -d

if [[ "$t_flag" == "true" ]]; then
echo "========= RUNNING TESTS ==========="
for file in ./shadows/* ; do
printf " TESTING: %s" "${file}..."
cdn_file=$(curl -ksi -X POST -H "Content-Type: multipart/form-data" -F "data=@${file}" "${ASH_HOST}"/ash/upload | tail -n1)
curl -ks "${ASH_HOST}"/"${cdn_file}" -o test
diff test "${file}"
echo " PASSED"
done

cleanup
fi

29 changes: 0 additions & 29 deletions layout.go

This file was deleted.

Loading