-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
16 changed files
with
98,339 additions
and
98,253 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 |
---|---|---|
@@ -1,45 +1,50 @@ | ||
name: Publish Docker image | ||
|
||
name: Build and publish | ||
on: | ||
create: | ||
tags: | ||
- 'v*' | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
build-and-publish: | ||
name: Build and publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
- name: Log in to GitHub container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
- name: Log in to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Extract metadata for docker image | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: th0th/is-email-disposable,ghcr.io/th0th/is-email-disposable | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
${{ github.repository }} | ||
tags: | | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
- name: Build and push docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,21 @@ | ||
linters: | ||
enable: | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- bodyclose | ||
- errorlint | ||
- exportloopref | ||
- gocritic | ||
- goprintffuncname | ||
- gosec | ||
- prealloc | ||
- whitespace | ||
linters-settings: | ||
gocritic: | ||
disabled-checks: | ||
- ifElseChain | ||
gosec: | ||
excludes: | ||
- G601 |
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,25 +1,19 @@ | ||
FROM golang:alpine AS builder | ||
FROM golang:1.23 | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=amd64 | ||
WORKDIR /usr/src/is-email-disposable | ||
|
||
WORKDIR /build | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
COPY cmd cmd | ||
COPY pkg pkg | ||
|
||
RUN mkdir bin | ||
|
||
RUN go build -o main . | ||
WORKDIR /dist | ||
RUN cp /build/main . | ||
RUN CGO_ENABLED=0 go build -a -o bin/rest-api cmd/restapi/* | ||
|
||
FROM scratch | ||
FROM alpine:3 | ||
|
||
COPY --from=builder /dist/main / | ||
COPY domains.json / | ||
COPY --from=0 /usr/src/is-email-disposable/bin/rest-api /usr/local/bin/is-email-disposable-rest-api | ||
|
||
ENTRYPOINT ["/main"] | ||
ENTRYPOINT ["is-email-disposable-rest-api"] |
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,37 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/go-errors/errors" | ||
"github.com/gofiber/contrib/fiberzerolog" | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/gofiber/fiber/v2/middleware/recover" | ||
"github.com/rs/zerolog/log" | ||
"github.com/th0th/is-email-disposable/pkg/common" | ||
"github.com/th0th/is-email-disposable/pkg/restapi/handler" | ||
"github.com/th0th/is-email-disposable/pkg/service/domain" | ||
) | ||
|
||
func main() { | ||
common.LogSetDefaults() | ||
|
||
domainService, err := domain.New() | ||
if err != nil { | ||
log.Panic().Stack().Err(errors.Wrap(err, 0)).Msg("email initialization failed") | ||
} | ||
|
||
app := fiber.New(fiber.Config{ | ||
DisableStartupMessage: true, | ||
}) | ||
|
||
app.Use(recover.New(recover.Config{EnableStackTrace: true, StackTraceHandler: func(c *fiber.Ctx, e interface{}) { | ||
log.Error().Stack().Err(errors.Wrap(e.(error), 0)).Msg("fiber panic") | ||
}})) | ||
app.Use(fiberzerolog.New()) | ||
|
||
app.Get("/", handler.Index(domainService)) | ||
|
||
err = app.Listen("0.0.0.0:81") | ||
if err != nil { | ||
log.Panic().Stack().Err(errors.Wrap(err, 0)).Msg("fiber listen failed") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.