Skip to main content

Dockerfile

React

# Use an official Node.js runtime20 ason the baseARM64 imageplatform (suitable for ARM-based systems like Apple Silicon)
FROM --platform=linux/arm64 node:1420-alpine AS builder

# Enable Corepack and prepare pnpm for managing dependencies
RUN corepack enable && corepack prepare pnpm@latest --activate

# Set an environment variable for the API URL (used by Vite in development)
ENV VITE_API_URL=http://localhost:8080

# Set the working directory inside the container
WORKDIR /app

# Copy dependency management files (package.json and package-pnpm-lock.jsonyaml) to the container
COPY package*.package.json pnpm-lock.yaml ./

# Install Node.jsproject dependencies using pnpm
RUN pnpm install

# Copy the rest of the application source code to the container
COPY . .

# Expose athe port that the applicationVite development server will listen onuse
EXPOSE 30005173

# DefineRun the commanddevelopment server with the --host flag to runbind yourit Node.jsto application0.0.0.0,
# making it accessible from outside the container
CMD ["pnpm", "dev", "--host"]
# Frontend Dockerfile
# Build stage
FROM node:20-alpine AS builder

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

ENV VITE_API_URL=

WORKDIR /app

# Copy package files
COPY package.json pnpm-lock.yaml ./

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy source code
COPY . .

# Build the application
RUN pnpm build

# Production stage
FROM nginx:alpine

# Copy built assets from builder
COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

Golang

# BuildPackager stage
FROM --platform=linux/arm64 golang:1.22.5 AS packager

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

# Builder stage
FROM --platform=linux/arm64 golang:1.22.5 AS builder

WORKDIR /app
COPY . ./
RUN goCGO_ENABLED=0 modGOOS=linux download

RUNGOARCH=arm64 go build -o /bin/appmain .

# Runtime stage
FROM --platform=linux/arm64 debian:buster-bullseye-slim AS runner

WORKDIR /app
COPY --from=buildbuilder /bin/appapp/main /bin.
COPY .env .env
EXPOSE 8080
CMD [ "/bin/app" app/main"]
# Buildpackger stage
FROM golang:1.22.5 AS builderpackger

# Set the working directory
WORKDIR /app

# Copy go.mod and go.sum files
COPY go.mod go.sum ./

# Download Go dependencies
RUN go mod download

# Build stage
FROM golang:1.22.5 AS builder

# Set the working directory
WORKDIR /app

# Copy the source code
COPY . .

# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./

# Runtime stage
FROM debian:bullseye-slim AS runner

# Set the working directory
WORKDIR /app

# Copy the built binary from the builder stage
COPY --from=builder /app/main .

# Expose the application's port
EXPOSE 8080

# Run the application
CMD ["/app/main"]