diff --git a/.gitignore b/.gitignore index a389b93..bfc9efe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,26 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# Allowlisting gitignore template for GO projects prevents us +# from adding various unwanted local files, such as generated +# files, developer configurations or IDE-specific files etc. # -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib +# Recommended: Go.AllowList.gitignore -# Test binary, built with `go test -c` -*.test +# Ignore everything +* -# Output of the go coverage tool, specifically when used with LiteIDE -*.out +# But not these files... +!/.gitignore -# Dependency directories (remove the comment below to include it) -# vendor/ +!*.go +!go.sum +!go.mod -# Go workspace file -go.work -go.work.sum +!docker-deploy.sh +!Dockerfile -# env file -.env +!README.md +!LICENSE # !Makefile # ...even if they are in subdirectories !*/ - -# ---> Custom -db diff --git a/Dockerfile b/Dockerfile index e78ca83..c00fc14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine WORKDIR /app -COPY noteserver . -RUN chmod +x /app/noteserver -CMD ["/app/noteserver"] +COPY . . +RUN apk update && apk add go && go build . +CMD ["./noteserver"] diff --git a/docker-deploy.sh b/docker-deploy.sh index fdcc38d..271867c 100755 --- a/docker-deploy.sh +++ b/docker-deploy.sh @@ -1,5 +1,11 @@ #!/bin/bash -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o noteserver . + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + echo "[#] sudo $0 $@" + exec sudo "$0" "$@" +fi + docker build -t noteserver . docker rm noteserver -docker run -d -p 80:3000 --name noteserver noteserver +docker run -d -p 3002:3000 --name noteserver noteserver diff --git a/noteserver b/noteserver index bf4085a..3494d59 100755 Binary files a/noteserver and b/noteserver differ