diff --git a/Makefile b/Makefile index 94017bd8..6cbaff4a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ +.PHONY: run tidy vendor build + +GO_CMD = go +GORELEASER_CMD = goreleaser + run: - go run main.go + $(GO_CMD) run main.go tidy: - go mod tidy + $(GO_CMD) mod tidy vendor: - go mod vendor + $(GO_CMD) mod vendor build: - goreleaser release --snapshot --skip=publish --clean --skip=sign \ No newline at end of file + $(GORELEASER_CMD) release --snapshot --skip=publish --clean --skip=sign diff --git a/debug.docker-compose.yml b/debug.docker-compose.yml new file mode 100644 index 00000000..738a6c10 --- /dev/null +++ b/debug.docker-compose.yml @@ -0,0 +1,27 @@ +# This is to run the alita-robot in debug mode with alpine image +# This starts up fast and does not do any optimizations +services: + alita: + build: + context: . + dockerfile: docker/debug.alpine + container_name: alita-robot + restart: always + env_file: + - .env + depends_on: + - mongodb + - redis + + mongodb: + image: mongo:latest + restart: always + env_file: + - .db.env + volumes: + - ./docker/entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro + + redis: + image: redis:latest + restart: always + command: redis-server --requirepass redisPassword diff --git a/docker-compose.yml b/docker-compose.yml index 745f6901..5987177e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +# This is to run the alita-robot in production mode with alpine image +# This does optimizations and builds slower services: alita: build: diff --git a/docker/alpine b/docker/alpine index 44a32d44..e22dde07 100644 --- a/docker/alpine +++ b/docker/alpine @@ -11,6 +11,7 @@ FROM alpine COPY --from=builder /app/out/alita_robot /app/alita_robot ENTRYPOINT ["/app/alita_robot"] +# Metadata LABEL org.opencontainers.image.authors="Divanshu Chauhan " LABEL org.opencontainers.image.url="https://divkix.me" LABEL org.opencontainers.image.source="https://github.com/divideprojects/Alita_Robot" diff --git a/docker/alpine.debug b/docker/alpine.debug new file mode 100644 index 00000000..27e319aa --- /dev/null +++ b/docker/alpine.debug @@ -0,0 +1,16 @@ +# Build Stage: Build bot using the alpine image +# This is an debug image, it will not compress the binary +FROM golang:alpine AS builder +RUN apk add --no-cache curl wget gnupg git upx +WORKDIR /app +COPY . . +RUN go build -o out/alita_robot +ENTRYPOINT ["/app/out/alita_robot"] + +# Metadata +LABEL org.opencontainers.image.authors="Divanshu Chauhan " +LABEL org.opencontainers.image.url="https://divkix.me" +LABEL org.opencontainers.image.source="https://github.com/divideprojects/Alita_Robot" +LABEL org.opencontainers.image.title="Alita Go Robot" +LABEL org.opencontainers.image.description="Official Alita Go Robot Debug Docker Image" +LABEL org.opencontainers.image.vendor="Divkix" diff --git a/docker/entrypoint-initdb.d/mongo-init.js b/docker/entrypoint-initdb.d/mongo-init.js index 44ac313d..3e5cb4b1 100644 --- a/docker/entrypoint-initdb.d/mongo-init.js +++ b/docker/entrypoint-initdb.d/mongo-init.js @@ -1,7 +1,9 @@ // Switch to the 'alita' database +// this is the database that we want to create the user in and store files in db = db.getSiblingDB('alita'); -// create a new user +// create a new basic user with readWrite role on the 'alita' database +// the user is 'admin' with password 'admin' db.createUser({ user: "admin", pwd: "admin", diff --git a/docker/goreleaser b/docker/goreleaser index 47f1f773..6ff46e79 100644 --- a/docker/goreleaser +++ b/docker/goreleaser @@ -2,6 +2,7 @@ FROM alpine COPY alita_robot / ENTRYPOINT ["/alita_robot"] +# Metadata LABEL org.opencontainers.image.authors="Divanshu Chauhan " LABEL org.opencontainers.image.url="https://divkix.me" LABEL org.opencontainers.image.source="https://github.com/divideprojects/Alita_Robot"