Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support to change the golang build image #23

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions runtime/bun.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func (d *Bun) GenerateDockerfile(path string) ([]byte, error) {

var bunTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM oven/bun:${VERSION} AS base
ARG BUILDER=docker.io/oven/bun
FROM ${BUILDER}:${VERSION} AS base

FROM base AS deps
WORKDIR /app
Expand All @@ -154,7 +155,7 @@ ENV NODE_ENV=production
ARG BUILD_CMD={{.BuildCMD}}
RUN if [ ! -z "${BUILD_CMD}" ]; then sh -c "$BUILD_CMD"; fi

FROM oven/bun:${VERSION}-slim AS runtime
FROM ${BUILDER}:${VERSION}-slim AS runtime
WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates && apt-get clean && rm -f /var/lib/apt/lists/*_*
Expand Down
3 changes: 2 additions & 1 deletion runtime/deno.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func (d *Deno) GenerateDockerfile(path string) ([]byte, error) {

var denoTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM denoland/deno:${VERSION} as base
ARG BUILDER=docker.io/denoland/deno
FROM ${BUILDER}:${VERSION} as base
FROM debian:stable-slim
WORKDIR /app
Expand Down
3 changes: 2 additions & 1 deletion runtime/elixir.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (d *Elixir) GenerateDockerfile(path string) ([]byte, error) {
var elixirTemplate = strings.TrimSpace(`
ARG VERSION={{.ElixirVersion}}
ARG OTP_VERSION={{.OTPVersion}}
FROM elixir:${VERSION}-otp-${OTP_VERSION}-slim AS build
ARG BUILDER=docker.io/library/elixir
FROM ${BUILDER}:${VERSION}-otp-${OTP_VERSION}-slim AS build
WORKDIR /app
RUN apt-get update -y && apt-get install -y build-essential git \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
Expand Down
3 changes: 2 additions & 1 deletion runtime/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (d *Golang) GenerateDockerfile(path string) ([]byte, error) {
var golangTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
ARG BUILDPLATFORM=linux/amd64
FROM --platform=${BUILDPLATFORM} golang:${VERSION} AS base
ARG BUILDER=docker.io/library/golang
FROM --platform=${BUILDPLATFORM} ${BUILDER}:${VERSION} AS base

FROM base AS deps
WORKDIR /go/src/app
Expand Down
3 changes: 2 additions & 1 deletion runtime/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ CMD ${START_CMD}
var javaGradleTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
ARG GRADLE_VERSION={{.GradleVersion}}
FROM gradle:${GRADLE_VERSION}-jdk${VERSION} AS build
ARG BUILDER=docker.io/library/gradle
FROM ${BUILDER}:${GRADLE_VERSION}-jdk${VERSION} AS build
WORKDIR /app

COPY build.gradle* gradlew* settings.gradle* ./
Expand Down
6 changes: 4 additions & 2 deletions runtime/nextjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func (d *NextJS) GenerateDockerfile(path string) ([]byte, error) {

var nextJSStandaloneTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM node:${VERSION}-slim AS base
ARG BUILDER=docker.io/library/node
FROM ${BUILDER}:${VERSION}-slim AS base

# Install dependencies only when needed
FROM base AS deps
Expand Down Expand Up @@ -172,7 +173,8 @@ CMD HOSTNAME="0.0.0.0" node server.js

var nextJSServerTemplate = strings.TrimSpace(`
ARG VERSION=lts
FROM node:${VERSION}-slim AS base
ARG BUILDER=docker.io/library/node
FROM ${BUILDER}:${VERSION}-slim AS base

# Install dependencies only when needed
FROM base AS deps
Expand Down
3 changes: 2 additions & 1 deletion runtime/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ var startScriptRe = regexp.MustCompile(`^.*?\b(ts-)?node(mon)?\b.*?(index|main|s

var nodeTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM node:${VERSION}-slim AS base
ARG BUILDER=docker.io/library/node
FROM ${BUILDER}:${VERSION}-slim AS base
RUN corepack enable

FROM base AS deps
Expand Down
3 changes: 2 additions & 1 deletion runtime/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ func (d *PHP) GenerateDockerfile(path string) ([]byte, error) {

var phpTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM composer:lts as build
ARG BUILDER=docker.io/library/composer
FROM ${BUILDER}:lts as build
RUN apk add --no-cache nodejs npm
WORKDIR /app
COPY . .
Expand Down
3 changes: 2 additions & 1 deletion runtime/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ func (d *Python) GenerateDockerfile(path string) ([]byte, error) {

var pythonTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM python:${VERSION}-slim
ARG BUILDER=docker.io/library/python
FROM ${BUILDER}:${VERSION}-slim
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates && apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN update-ca-certificates 2>/dev/null || true
Expand Down
3 changes: 2 additions & 1 deletion runtime/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func (d *Ruby) GenerateDockerfile(path string) ([]byte, error) {

var rubyTemplate = strings.TrimSpace(`
ARG VERSION={{.Version}}
FROM ruby:${VERSION}-slim
ARG BUILDER=docker.io/library/ruby
FROM ${BUILDER}:${VERSION}-slim
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates && apt-get clean && rm -f /var/lib/apt/lists/*_*
RUN update-ca-certificates 2>/dev/null || true
Expand Down
3 changes: 2 additions & 1 deletion runtime/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func (d *Rust) GenerateDockerfile(path string) ([]byte, error) {

var rustlangTemplate = strings.TrimSpace(`
ARG BUILDPLATFORM=linux
FROM --platform=${BUILDPLATFORM} messense/cargo-zigbuild:latest AS build
ARG BUILDER=docker.io/messense/cargo-zigbuild
FROM --platform=${BUILDPLATFORM} ${BUILDER}:latest AS build
WORKDIR /app
COPY . .

Expand Down
3 changes: 2 additions & 1 deletion runtime/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func (d *Static) GenerateDockerfile(path string) ([]byte, error) {

var staticTemplate = strings.TrimSpace(`
ARG VERSION=2
FROM joseluisq/static-web-server:${VERSION}-debian
ARG BUILDER=docker.io/joseluisq/static-web-server
FROM ${BUILDER}:${VERSION}-debian
RUN apt-get update && apt-get install -y --no-install-recommends wget && apt-get clean && rm -f /var/lib/apt/lists/*_*
COPY . .

Expand Down