Skip to content

Commit

Permalink
Some fixes for docker and make session_maker.sh executable (#6)
Browse files Browse the repository at this point in the history
* Add docker-compose

* Dockerfile: use latest images for bot

* update sample config for full postgres uri example
  • Loading branch information
Divkix committed Aug 3, 2022
1 parent 0d4b4c1 commit 12f0440
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**
!modules
!sql
!utils
!*.go
!go.*
!config*
!vendor
18 changes: 7 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Build Stage: Build bot using the alpine image, also install doppler in it
FROM golang:1.18-alpine AS builder
RUN addgroup -S scratchuser \
&& adduser -S -u 10000 -g scratchuser scratchuser
RUN apk add -U --no-cache ca-certificates
FROM golang:latest AS builder
RUN apt-get update && apt-get upgrade -y && apt-get install build-essential -y
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o out/GigaUserbot -ldflags="-w -s" .
RUN GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o out/GigaUserbot -ldflags="-w -s" .

# Run Stage: Run bot using the bot and doppler binary copied from build stage
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/out/GigaUserbot /
COPY --from=builder /etc/passwd /etc/passwd
USER scratchuser
CMD ["/GigaUserbot"]
FROM ubuntu:latest
COPY --from=builder /app/out/GigaUserbot /app/GigaUserbot
COPY config.json config.json
CMD ["/app/GigaUserbot"]
18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.9'
services:
db:
image: postgres:latest
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
giga-ub:
image: giga-ub
restart: always
build:
context: .
dockerfile: Dockerfile
links:
- db
depends_on:
- db
10 changes: 5 additions & 5 deletions sample_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app_id":12345,
"api_hash":"hash",
"db_uri": "postgres://",
"session_string":"string"
}
"app_id": 12345,
"api_hash": "hash",
"db_uri": "postgres://postgres:postgres@db:5432/postgres",
"session_string": "string"
}
Empty file modified session_maker.sh
100644 → 100755
Empty file.

0 comments on commit 12f0440

Please sign in to comment.