diff --git a/.env b/.env deleted file mode 100644 index 5c01d57..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -JWT_SECRET=cab2f6a968c2a11601bb33c41c5940b7 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 319175e..a9a8fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ secrets.json flaticon_svgs flaticon_colored_svgs +icons diff --git a/Dockerfile b/Dockerfile index 944c04e..18ccabd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ VOLUME /app/data/icons # Copy go.mod and go.sum files COPY go.mod go.sum ./ + # Download all dependencies RUN go mod download @@ -24,7 +25,7 @@ RUN go build FROM debian:bookworm-slim #ENV FRONTEND_HOST=https://app.nkode.tech -ENV FRONTEND_HOST=http://localhost:8090 +#ENV FRONTEND_HOST=http://localhost:8090 ENV SVG_DIR=/app/data/icons ENV DB_PATH=/app/data/sqlite/nkode.db ENV SQLITE_DB=/app/data/sqlite/nkode.db diff --git a/api.nkode.tech b/api.nkode.tech deleted file mode 100644 index 8d3af1c..0000000 --- a/api.nkode.tech +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 443 ssl http2; - server_name api.nkode.tech; - - ssl_certificate /etc/letsencrypt/live/api.nkode.tech/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/api.nkode.tech/privkey.pem; - ssl_protocols TLSv1.2 TLSv1.3; - ssl_prefer_server_ciphers on; - ssl_dhparam /etc/ssl/certs/dhparam.pem; - ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - ssl_stapling on; - ssl_stapling_verify on; - resolver 8.8.8.8 8.8.4.4 valid=300s; - resolver_timeout 5s; - - add_header X-Content-Type-Options nosniff; - add_header X-Frame-Options DENY; - add_header X-XSS-Protection "1; mode=block"; - add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; - - location / { - proxy_pass http://127.0.0.1:8080; # Your application port - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} - -server { - listen 80; - server_name api.nkode.tech; - - # Redirect all HTTP traffic to HTTPS - return 301 https://$host:443$request_uri; -} diff --git a/compose/coolify_compose.yaml b/compose/coolify_compose.yaml new file mode 100644 index 0000000..2112488 --- /dev/null +++ b/compose/coolify_compose.yaml @@ -0,0 +1,11 @@ +services: + go-nkode: + container_name: go-nkode + image: registry.infra.nkode.tech/go-nkode + volumes: + - /var/go-nkode/sqlite:/app/data/sqlite + - /var/go-nkode/icons:/app/data/icons + + environment: + - JWT_SECRET=${JWT_SECRET} + - FRONTEND_HOST=https://app.nkode.tech diff --git a/compose.yaml b/compose/local_compose.yaml similarity index 51% rename from compose.yaml rename to compose/local_compose.yaml index 0b3246f..e7049d2 100644 --- a/compose.yaml +++ b/compose/local_compose.yaml @@ -1,16 +1,13 @@ -version: '3.9' - services: go-nkode: container_name: go-nkode - image: registry.donovankelly.dev/go-nkode + image: registry.infra.nkode.tech/go-nkode volumes: - /var/go-nkode/sqlite:/app/data/sqlite - /var/go-nkode/icons:/app/data/icons - # .env should contain JWT_SECRET - env_file: - - .env - + environment: + - JWT_SECRET=0123456789 + - FRONTEND_HOST=http://localhost:8090 ports: - - "8080:8080" \ No newline at end of file + - "8070:8080" \ No newline at end of file diff --git a/deploy_api.sh b/deploy_api.sh deleted file mode 100644 index f960970..0000000 --- a/deploy_api.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Create a temporary directory to hold the files -#mkdir -p /tmp/nkodeapi -# -#cp -r ./core/* /tmp/nkodeapi/ -#cp -r ./hashset/* /tmp/nkodeapi/ -#cp -r ./py-builtin/* /tmp/nkodeapi/ -#cp -r ./util/* /tmp/nkodeapi/ -# -#cp go.mod /tmp/nkodeapi/ -#cp main.go /tmp/nkodeapi/ - - -# Disable extended attributes and create the tar file -export COPYFILE_DISABLE=1 -tar -cvf go-nkode.tar -C ../ go-nkode - - -#scp go-nkode.tar dkelly@api.nkode.tech:/home/dkelly - -scp api.nkode.tech dkelly@217.21.78.137:/home/dkelly -scp go-nkode.tar dkelly@217.21.78.137:/home/dkelly - -rm go-nkode.tar diff --git a/docker_build.sh b/docker_build.sh deleted file mode 100644 index 55acca3..0000000 --- a/docker_build.sh +++ /dev/null @@ -1 +0,0 @@ -docker build -t go-nkode . \ No newline at end of file diff --git a/docker_run.sh b/docker_run.sh deleted file mode 100644 index 236e43e..0000000 --- a/docker_run.sh +++ /dev/null @@ -1,5 +0,0 @@ -docker run --name go-nkode -p 8080:8080 \ - -v /Users/donov/databases/:/app/data/sqlite \ - -v /Users/donov/Desktop/go-nkode/core/sqlite-init/flaticon_colored_svgs/:/app/data/icons \ - -e JWT_SECRET=cab2f6a968c2a11601bb33c41c5940b7 \ - go-nkode \ No newline at end of file diff --git a/go.mod b/go.mod index 1c77d0c..22bbd66 100644 --- a/go.mod +++ b/go.mod @@ -9,11 +9,9 @@ require ( github.com/mattn/go-sqlite3 v1.14.22 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.26.0 - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 ) require ( - github.com/aws/aws-sdk-go v1.55.5 // indirect github.com/aws/aws-sdk-go-v2 v1.31.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.27.37 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.35 // indirect diff --git a/backup_sqlite.sh b/script/backup_sqlite.sh similarity index 100% rename from backup_sqlite.sh rename to script/backup_sqlite.sh diff --git a/script/docker_build.sh b/script/docker_build.sh new file mode 100644 index 0000000..26b89f7 --- /dev/null +++ b/script/docker_build.sh @@ -0,0 +1 @@ +docker buildx build --platform linux/amd64,linux/arm64 -t registry.infra.nkode.tech/go-nkode:latest --push . diff --git a/secure_bytes.sh b/secure_bytes.sh deleted file mode 100644 index d9f7692..0000000 --- a/secure_bytes.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Define the number of bytes you want to generate -num_bytes=16 - -# Use dd to read cryptographically secure bytes from /dev/urandom -# and convert them to hexadecimal using od -secure_bytes=$(dd if=/dev/urandom bs=1 count=$num_bytes 2>/dev/null | od -An -tx1) - -# Remove leading/trailing spaces and concatenate the hex bytes into a single string -secure_bytes=$(echo $secure_bytes | tr -d ' \n') - -# Output the result as a hexadecimal string -echo "Cryptographically secure bytes (as hex): $secure_bytes"