From 80c15e9a52b952e3af6f5f873f510754f82da9e4 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 17:13:03 -0600 Subject: [PATCH 01/18] interperable port --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 0b3246f..ea76e3c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,4 +13,4 @@ services: - .env ports: - - "8080:8080" \ No newline at end of file + - "{PORT}:{PORT}" \ No newline at end of file From a0a698677a8c852eada0cf2009cc54edb436cf2f Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 17:19:20 -0600 Subject: [PATCH 02/18] remove ports --- compose.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index ea76e3c..2531c7a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,6 +11,3 @@ services: # .env should contain JWT_SECRET env_file: - .env - - ports: - - "{PORT}:{PORT}" \ No newline at end of file From 23e6e54c4ee5cb32f1f387f6e8cee5c9a50baca6 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 17:23:31 -0600 Subject: [PATCH 03/18] remove image and add build --- compose.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 2531c7a..d999993 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,7 +3,8 @@ version: '3.9' services: go-nkode: container_name: go-nkode - image: registry.donovankelly.dev/go-nkode + build: # This tells Docker Compose to build the image first + context: . volumes: - /var/go-nkode/sqlite:/app/data/sqlite - /var/go-nkode/icons:/app/data/icons From ad42f6289c902b65d8ca5f8ef059de8a1f9a8d7e Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 17:25:54 -0600 Subject: [PATCH 04/18] add jwt secret as ${JWT_SECRET} --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index d999993..2f5c3d5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,5 +10,5 @@ services: - /var/go-nkode/icons:/app/data/icons # .env should contain JWT_SECRET - env_file: - - .env + environment: + - JWT_SECRET=${JWT_SECRET} From 3d0d06f2cc24d7a46d3c556fc5ba480388554ed0 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 19:48:21 -0600 Subject: [PATCH 05/18] fix proxy error --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 944c04e..0328a66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,8 @@ VOLUME /app/data/icons # Copy go.mod and go.sum files COPY go.mod go.sum ./ +ENV GOPROXY=direct + # Download all dependencies RUN go mod download From 1fa0ee9d093405197d6e6cab43bf6b23ba99477f Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:05:06 -0600 Subject: [PATCH 06/18] test network --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 0328a66..025f611 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ VOLUME /app/data/icons COPY go.mod go.sum ./ ENV GOPROXY=direct +RUN curl -I https://github.com # Download all dependencies RUN go mod download From 9283e638eaee1e65f48994f74ee54617490b0b91 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:15:21 -0600 Subject: [PATCH 07/18] test network --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 025f611..3956d90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,8 @@ VOLUME /app/data/icons # Copy go.mod and go.sum files COPY go.mod go.sum ./ -ENV GOPROXY=direct -RUN curl -I https://github.com +RUN curl -I https://proxy.golang.org +RUN curl -I https://sum.golang.org # Download all dependencies RUN go mod download From 0024a58eb49c133b6f96a4e84a2f92e9a3202ad6 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:16:38 -0600 Subject: [PATCH 08/18] test network --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3956d90..8c6897a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,7 @@ VOLUME /app/data/icons # Copy go.mod and go.sum files COPY go.mod go.sum ./ -RUN curl -I https://proxy.golang.org -RUN curl -I https://sum.golang.org +RUN curl -I https://proxy.golang.org/github.com/aws/aws-sdk-go/@v/v1.55.5.zip # Download all dependencies RUN go mod download From ba9be11f934af30bc2fa807287292f5ae8f45074 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:25:50 -0600 Subject: [PATCH 09/18] trying different go version --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c6897a..0f25a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM golang:1.23 AS builder +FROM golang:1.21 AS builder # Set the working directory inside the container WORKDIR /app @@ -11,7 +11,6 @@ VOLUME /app/data/icons # Copy go.mod and go.sum files COPY go.mod go.sum ./ -RUN curl -I https://proxy.golang.org/github.com/aws/aws-sdk-go/@v/v1.55.5.zip # Download all dependencies RUN go mod download From 3fe7c47ed18e4a8200064bbe6e5cceace9d00fca Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:26:44 -0600 Subject: [PATCH 10/18] trying different go version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0f25a4b..e17e04b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM golang:1.21 AS builder +FROM golang:1.22 AS builder # Set the working directory inside the container WORKDIR /app From e12225175166962b3df74827229126dcbc539026 Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:29:16 -0600 Subject: [PATCH 11/18] remove module that gives error --- go.mod | 2 -- 1 file changed, 2 deletions(-) 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 From c2b6533c6e084559b4ed1f0a081e3724116bc96e Mon Sep 17 00:00:00 2001 From: Donovan Date: Wed, 20 Nov 2024 20:29:21 -0600 Subject: [PATCH 12/18] remove module that gives error --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e17e04b..9cb3b79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Build -FROM golang:1.22 AS builder +FROM golang:1.23 AS builder # Set the working directory inside the container WORKDIR /app From 6542227cc536669badcb745f3bb03412d3d6cc13 Mon Sep 17 00:00:00 2001 From: Donovan Date: Sun, 24 Nov 2024 10:15:03 -0600 Subject: [PATCH 13/18] add icons folder to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 2a038661801e89b92043c7be5b721ea8cd0a2888 Mon Sep 17 00:00:00 2001 From: Donovan Date: Mon, 25 Nov 2024 10:11:24 -0600 Subject: [PATCH 14/18] remame coolify_compose.yaml remove old scripts --- .env | 1 - Dockerfile | 8 ++++---- compose.yaml => coolify_compose.yaml | 10 +++++----- deploy_api.sh | 25 ------------------------- docker_build.sh | 2 +- docker_run.sh | 5 ----- secure_bytes.sh | 14 -------------- 7 files changed, 10 insertions(+), 55 deletions(-) delete mode 100644 .env rename compose.yaml => coolify_compose.yaml (54%) delete mode 100644 deploy_api.sh delete mode 100644 docker_run.sh delete mode 100644 secure_bytes.sh 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/Dockerfile b/Dockerfile index 9cb3b79..9a700c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,10 +25,10 @@ RUN go build FROM debian:bookworm-slim #ENV FRONTEND_HOST=https://app.nkode.tech -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 +#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 # Set the working directory inside the runtime container WORKDIR /app diff --git a/compose.yaml b/coolify_compose.yaml similarity index 54% rename from compose.yaml rename to coolify_compose.yaml index 2f5c3d5..53ee3fb 100644 --- a/compose.yaml +++ b/coolify_compose.yaml @@ -1,14 +1,14 @@ -version: '3.9' - services: go-nkode: container_name: go-nkode - build: # This tells Docker Compose to build the image first - context: . + 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 environment: - JWT_SECRET=${JWT_SECRET} + - FRONTEND_HOST=${FRONTEND_HOST} + - SVG_DIR=${SVG_DIR} + - DB_PATH=${DB_PATH} + - SQLITE_DB=${SQLITE_DB} 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 index 55acca3..26b89f7 100644 --- a/docker_build.sh +++ b/docker_build.sh @@ -1 +1 @@ -docker build -t go-nkode . \ No newline at end of file +docker buildx build --platform linux/amd64,linux/arm64 -t registry.infra.nkode.tech/go-nkode:latest --push . 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/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" From e1df64e708dbe8cd54af99f3c505f79eb918e7b5 Mon Sep 17 00:00:00 2001 From: Donovan Date: Mon, 25 Nov 2024 10:11:58 -0600 Subject: [PATCH 15/18] move scripts to folder --- backup_sqlite.sh => script/backup_sqlite.sh | 0 docker_build.sh => script/docker_build.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename backup_sqlite.sh => script/backup_sqlite.sh (100%) rename docker_build.sh => script/docker_build.sh (100%) 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/docker_build.sh b/script/docker_build.sh similarity index 100% rename from docker_build.sh rename to script/docker_build.sh From aef6f000a1beca2aadae8933e4bcbffc40dc1247 Mon Sep 17 00:00:00 2001 From: Donovan Date: Mon, 25 Nov 2024 10:12:32 -0600 Subject: [PATCH 16/18] remove nginx --- api.nkode.tech | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 api.nkode.tech 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; -} From f18b88934e64b11ae4faded9fc82dd56d299a6de Mon Sep 17 00:00:00 2001 From: Donovan Date: Mon, 25 Nov 2024 10:12:42 -0600 Subject: [PATCH 17/18] move compose to its own folder --- coolify_compose.yaml => compose/coolify_compose.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename coolify_compose.yaml => compose/coolify_compose.yaml (100%) diff --git a/coolify_compose.yaml b/compose/coolify_compose.yaml similarity index 100% rename from coolify_compose.yaml rename to compose/coolify_compose.yaml From f6e8fde567dd080983c79c4a1723201cb3a205eb Mon Sep 17 00:00:00 2001 From: Donovan Date: Mon, 25 Nov 2024 13:06:55 -0600 Subject: [PATCH 18/18] add local compose --- Dockerfile | 6 +++--- compose/coolify_compose.yaml | 5 +---- compose/local_compose.yaml | 13 +++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 compose/local_compose.yaml diff --git a/Dockerfile b/Dockerfile index 9a700c6..18ccabd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,9 @@ FROM debian:bookworm-slim #ENV FRONTEND_HOST=https://app.nkode.tech #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 +ENV SVG_DIR=/app/data/icons +ENV DB_PATH=/app/data/sqlite/nkode.db +ENV SQLITE_DB=/app/data/sqlite/nkode.db # Set the working directory inside the runtime container WORKDIR /app diff --git a/compose/coolify_compose.yaml b/compose/coolify_compose.yaml index 53ee3fb..2112488 100644 --- a/compose/coolify_compose.yaml +++ b/compose/coolify_compose.yaml @@ -8,7 +8,4 @@ services: environment: - JWT_SECRET=${JWT_SECRET} - - FRONTEND_HOST=${FRONTEND_HOST} - - SVG_DIR=${SVG_DIR} - - DB_PATH=${DB_PATH} - - SQLITE_DB=${SQLITE_DB} + - FRONTEND_HOST=https://app.nkode.tech diff --git a/compose/local_compose.yaml b/compose/local_compose.yaml new file mode 100644 index 0000000..e7049d2 --- /dev/null +++ b/compose/local_compose.yaml @@ -0,0 +1,13 @@ +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=0123456789 + - FRONTEND_HOST=http://localhost:8090 + ports: + - "8070:8080" \ No newline at end of file