-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
d.pikaliuk
committed
Jan 12, 2024
1 parent
d530e67
commit a00e81e
Showing
10 changed files
with
120 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v1.*.*' | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and Push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
file: ./cicd/dockerfiles/insta-bot.Dockerfile | ||
context: . | ||
push: true | ||
tags: haski007/insta-bot:${{ github.ref_name }} | ||
|
||
- name: Run Docker Compose | ||
run: | | ||
docker-compose -f docker-compose.yml up --build -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM golang:1.21 as builder | ||
|
||
# Set the working dixrectory in the container | ||
WORKDIR /app | ||
|
||
# Copy the Go modules and sum files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download Go module dependencies | ||
RUN go mod download | ||
|
||
# Copy the rest of the source code | ||
COPY . . | ||
|
||
# Build the application | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o insta-bot ./cmd/app | ||
|
||
# Use a small image to run the application | ||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
|
||
WORKDIR /root/ | ||
|
||
# Copy the pre-built binary file from the previous stage | ||
COPY --from=builder /app/insta-bot . | ||
COPY --from=builder /app/token.json . | ||
|
||
|
||
# Command to run the executable | ||
CMD ["./insta-bot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package factory | ||
|
||
import "time" | ||
|
||
type TelegramBotCfg struct { | ||
Token string `json:"token" yaml:"token"` | ||
CreatorUserID int64 `json:"creator_user_id" yaml:"creator_user_id"` | ||
UpdatesTimeoutSec int `json:"updates_timeout_sec" yaml:"updates_timeout_sec"` | ||
Token string `json:"token" yaml:"token" env:"BOT_TOKEN"` | ||
CreatorUserID int64 `json:"creator_user_id" yaml:"creator_user_id" env:"BOT_CREATOR_USER_ID"` | ||
UpdatesTimeout time.Duration `json:"updates_timeout" yaml:"updates_timeout" env:"BOT_UPDATES_TIMEOUT"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters