mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
Updated Dockerfiles for ARM Support
This commit is contained in:
parent
176dfac0c1
commit
c3536ce715
42
Dockerfile
42
Dockerfile
@ -1,47 +1,51 @@
|
||||
# Builder Stage
|
||||
FROM node:20-alpine AS builder
|
||||
FROM --platform=$BUILDPLATFORM node:20-alpine AS builder
|
||||
|
||||
ARG TARGETARCH # Wird automatisch von Buildx gesetzt
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN case ${TARGETARCH} in \
|
||||
"amd64") export PRISMA_CLI_BINARY_TARGETS="linux-musl-x64-openssl-3.0.x" ;; \
|
||||
"arm64") export PRISMA_CLI_BINARY_TARGETS="linux-musl-arm64-openssl-3.0.x" ;; \
|
||||
"arm") export PRISMA_CLI_BINARY_TARGETS="linux-musl-arm-openssl-3.0.x" ;; \
|
||||
*) echo "Unsupported ARCH: ${TARGETARCH}" && exit 1 ;; \
|
||||
esac
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
COPY ./prisma ./prisma
|
||||
|
||||
# Install all dependencies (including devDependencies)
|
||||
RUN npm install
|
||||
|
||||
# Generate Prisma client
|
||||
RUN npx prisma generate
|
||||
|
||||
# Build the application
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Production Stage
|
||||
FROM node:20-alpine AS production
|
||||
FROM --platform=$TARGETPLATFORM node:20-alpine AS production
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
ENV PRISMA_CLI_BINARY_TARGETS="linux-musl-arm64-openssl-3.0.x"
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# Copy node_modules from builder
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Remove dev dependencies
|
||||
RUN npm prune --production
|
||||
|
||||
# Copy Prisma files
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
|
||||
# Copy built application
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/next.config.js* ./
|
||||
|
||||
EXPOSE 3000
|
||||
RUN npm prune --production
|
||||
|
||||
# Run migrations and start
|
||||
EXPOSE 3000
|
||||
CMD ["sh", "-c", "npx prisma migrate deploy && npm start"]
|
||||
|
||||
|
||||
# - - BUILD COMMAND - -
|
||||
# docker buildx build \
|
||||
# --platform linux/amd64,linux/arm64,linux/arm/v7 \
|
||||
# -t haedlessdev/corecontrol:1.0.0 \
|
||||
# -t haedlessdev/corecontrol:latest \
|
||||
# --push \
|
||||
# .
|
||||
@ -1,25 +1,45 @@
|
||||
# --- Build Stage ---
|
||||
FROM golang:1.19-alpine AS builder
|
||||
# Multi-Arch Builder mit expliziter Plattform-Angabe
|
||||
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS builder
|
||||
|
||||
ARG TARGETOS TARGETARCH
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV GO111MODULE=on
|
||||
ENV GO111MODULE=on \
|
||||
CGO_ENABLED=0 \
|
||||
GOOS=$TARGETOS \
|
||||
GOARCH=$TARGETARCH
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go build -o app ./cmd/agent
|
||||
# Cross-Compile für Zielarchitektur
|
||||
RUN go build -ldflags="-w -s" -o app ./cmd/agent
|
||||
|
||||
# --- Run Stage ---
|
||||
# Multi-Arch Laufzeit-Image
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
# Notwendig für TLS/SSL-Zertifikate
|
||||
RUN apk --no-cache add ca-certificates gcompat
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=builder /app/app .
|
||||
|
||||
# Security Hardening
|
||||
USER nobody:nobody
|
||||
ENV GOMAXPROCS=1
|
||||
|
||||
CMD ["./app"]
|
||||
|
||||
# - - BUILD COMMAND - -
|
||||
# docker buildx build \
|
||||
# --platform linux/amd64,linux/arm64,linux/arm/v7 \
|
||||
# -t haedlessdev/corecontrol-agent:1.0.0 \
|
||||
# -t haedlessdev/corecontrol-agent:latest \
|
||||
# --push \
|
||||
# .
|
||||
Loading…
x
Reference in New Issue
Block a user