Last active
March 17, 2024 21:37
-
-
Save adoublef/6cb7796a2df0ef099abd5ed86519f0b6 to your computer and use it in GitHub Desktop.
OCI
This file contains hidden or 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
# syntax=docker/dockerfile:1 | |
ARG GO_VERSION=1.21 | |
ARG DISTROLESS=static-debian11:nonroot-amd64 | |
FROM golang:${GO_VERSION} AS base | |
WORKDIR /usr/src | |
COPY go.* . | |
RUN go mod download | |
COPY . . | |
FROM base AS test | |
RUN go test -v -cover -count 1 ./... | |
FROM base AS build | |
# cgo needed for litefs | |
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \ | |
-ldflags "-s -w -extldflags '-static'" \ | |
-buildvcs=false \ | |
-tags osusergo,netgo \ | |
-o /usr/bin/a ./cmd/slowmoon/ | |
FROM alpine AS deploy | |
WORKDIR /opt | |
ARG LITEFS_CONFIG="litefs.yml" | |
ENV LITEFS_DIR="/litefs" | |
ENV DATA_SOURCE_IAM="file:${LITEFS_DIR}/iam.db" | |
ENV DATA_SOURCE_PROJECTS="file:${LITEFS_DIR}/projects.db" | |
ENV INTERNAL_PORT=8080 | |
ENV PORT=8081 | |
# copy binary from build | |
COPY --from=build /usr/bin/a . | |
# install sqlite, ca-certificates, curl and fuse for litefs | |
RUN apk add --no-cache bash fuse3 sqlite ca-certificates curl | |
# prepar for litefs | |
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs | |
ADD litefs/${LITEFS_CONFIG} /etc/litefs.yml | |
RUN mkdir -p /data ${LITEFS_DIR} | |
# prepare for atlas | |
COPY --from=arigaio/atlas:latest-alpine /atlas /usr/local/bin/atlas | |
ADD internal/projects/sqlite3/schema.sql ./projects.sql | |
ADD internal/iam/sqlite3/schema.sql ./iam.sql | |
ADD atlas.hcl ./atlas.hcl | |
FROM deploy AS local | |
# prepare infisical | |
RUN curl -1sLf \ | |
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \ | |
&& apk add infisical | |
ENTRYPOINT [ "litefs", "mount"] | |
FROM deploy AS final | |
ENTRYPOINT [ "litefs", "mount"] |
This file contains hidden or 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
FROM debian:11.6-slim as builder | |
WORKDIR /app | |
RUN apt update | |
RUN apt install curl unzip -y | |
RUN curl https://bun.sh/install | bash | |
COPY package.json . | |
COPY bun.lockb . | |
RUN /root/.bun/bin/bun install --production | |
# ? ------------------------- | |
FROM gcr.io/distroless/cc | |
WORKDIR /app | |
COPY --from=builder /root/.bun/bin/bun bun | |
COPY --from=builder /app/node_modules node_modules | |
COPY . . | |
COPY tsconfig.json . | |
# COPY public public | |
ENV NODE_ENV production | |
CMD ["./bun", "main.ts"] | |
EXPOSE 8000 |
This file contains hidden or 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
ARG DENO_VERSION=1.37.0 | |
FROM denoland/deno:${DENO_VERSION} AS build | |
WORKDIR /app | |
# USER deno | |
COPY deno.* deps.ts ./ | |
RUN deno cache deps.ts | |
ADD . . | |
RUN deno cache main.ts | |
# ? -------------------------------- | |
FROM gcr.io/distroless/cc AS final | |
WORKDIR /app | |
COPY --from=build /etc/passwd /etc/passwd | |
COPY --from=build /etc/group /etc/group | |
COPY --from=build --chown=deno:deno /deno-dir /root/.cache/deno | |
COPY --from=build --chown=deno:deno /usr/bin/deno deno | |
COPY . . | |
CMD ["./deno", "run", "-A", "--unstable", "main.ts"] | |
EXPOSE 8000 |
This file contains hidden or 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
# syntax=docker/dockerfile:1 | |
ARG GO_VERSION=1.21 | |
ARG ALPINE_VERSION=3.18 | |
FROM golang:${GO_VERSION} AS build | |
WORKDIR /usr/src | |
COPY go.* . | |
RUN go mod download | |
COPY . . | |
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \ | |
-ldflags "-s -w -extldflags '-static'" \ | |
-buildvcs=false \ | |
-tags osusergo,netgo \ | |
-o /usr/bin/a . | |
FROM alpine:${ALPINE_VERSION} AS runtime | |
WORKDIR /opt | |
# copy binary from build | |
COPY --from=build /usr/bin/a ./ | |
CMD ["./a"] | |
EXPOSE 8080 |
This file contains hidden or 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
FROM node:16-alpine as base | |
RUN corepack enable && \ | |
corepack prepare pnpm@latest-8 --activate | |
FROM base AS deps | |
WORKDIR /app | |
COPY package.json pnpm-lock.yaml ./ | |
RUN pnpm fetch --dev && \ | |
pnpm install --offline --dev | |
FROM base as build | |
WORKDIR /app | |
COPY . . | |
COPY --from=deps /app/node_modules ./node_modules | |
RUN pnpm build && \ | |
pnpm prune --prod | |
FROM base as deploy | |
WORKDIR /app | |
COPY --from=build /app/package.json ./ | |
COPY --from=build /app/build ./ | |
COPY --from=build /app/node_modules ./node_modules | |
EXPOSE 8080 | |
CMD ["node", "index.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment