Skip to content

Instantly share code, notes, and snippets.

@Guiwoo
Created April 3, 2024 01:31
Show Gist options
  • Save Guiwoo/dfbf63eacf4f2c30067a5daaa5bb73ef to your computer and use it in GitHub Desktop.
Save Guiwoo/dfbf63eacf4f2c30067a5daaa5bb73ef to your computer and use it in GitHub Desktop.
dockerfile help
FROM golang:1.22.1-alpine3.19 AS builder
ARG GIT_USER=hsadiaigit
ARG GIT_PRIVATE_TOKEN
ARG GO_PRIVATE=github.com/hsadiaigit/ai_platform_common
ENV CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
CONFIG_FILE=.env
WORKDIR /build
COPY . .
#RUN apk update && apk add git
RUN apk add git
RUN git config \
--global \
url."https://${GIT_USER}:${GIT_PRIVATE_TOKEN}@github.com/".insteadOf "https://github.com/"
RUN go env -w GOPRIVATE=${GO_PRIVATE}
RUN go env
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/ai_platform_image ./cmd/main.go
FROM alpine:latest AS runtime
ENV CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
CONFIG_FILE=/app/bin/.env \
PROGRAM=ai_platform_image
COPY --from=builder /build/bin/ai_platform_image /app/bin/
COPY --from=builder /build/.env.dev /app/bin/.env
COPY --from=builder /build/workprocess/workflow_common.json /app/etc/workflow_common.json
RUN mkdir -p /app/logs
RUN apk add chromium
ARG ENV_TZ=Asia/Seoul
ENV TZ=${ENV_TZ}
RUN apk add --no-cache tzdata
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime
RUN echo $TZ > /etc/timezone
ENV LANG=ko_KR.UTF-8
ENV LANGUAGE=ko_KR.UTF-8
RUN cat /app/bin/.env
EXPOSE 80
ENTRYPOINT /app/bin/${PROGRAM}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment