Skip to content

Instantly share code, notes, and snippets.

View monirz's full-sized avatar
💻
Focusing

Moniruzzaman Monir monirz

💻
Focusing
View GitHub Profile
package main
import (
"bufio"
"crypto/tls"
"fmt"
"log"
"os"
gremlingo "github.com/apache/tinkerpop/gremlin-go/v3/driver"
@monirz
monirz / Dockerfile
Last active February 25, 2023 06:29
Golang Dockerfile multi stage build
# Build stage
FROM golang:1.19.3-alpine AS build
ENV CGO_ENABLED=0
ENV GO111MODULE=on
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go build -o /server
package handler
import (
"io"
"io/ioutil"
"log"
"mime/multipart"
"net/http"
"runtime"
)
func (s *Server) uploadFileHandler(w http.ResponseWriter, r *http.Request) {
// Get the file from the request
err := r.ParseMultipartForm(10 << 20)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"runtime"
"sync"
CREATE TABLE batches(
id NUMBER(19) GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY,
user_id VARCHAR2(50) NOT NULL,
bId VARCHAR2(50) UNIQUE NOT NULL,
actionType NUMBER(3) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
package main
import (
"context"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"sync"
FROM golang:1.14-alpine
ENV GO111MODULE=on
ENV PORT=8090
WORKDIR /app/server
COPY go.mod .
RUN go mod download
COPY . .
FROM golang:1.12
ENV GO111MODULE=on
ENV PORT=9000
WORKDIR /app/server
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
FROM golang:1.12
ENV PORT=9000
WORKDIR /app/server
COPY . .
RUN go get ./...
RUN go build
CMD ["./server"]