Skip to content

Commit

Permalink
Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jnnngs committed Jun 18, 2024
1 parent 8c5ecc7 commit 319cb74
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
62 changes: 62 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# syntax=docker/dockerfile:1.2

#############################
# Builder for Linux
#############################
FROM golang:1.20 AS builder-linux

# Set environment variables for Linux
ENV GOARCH=amd64
ENV GOOS=linux

# Set the working directory
WORKDIR /app

# Copy the Go source code
COPY . .

# Build the Linux binary
RUN go build -o 3270Connect-linux go3270Connect.go

#############################
# Builder for Windows
#############################
FROM golang:1.20 AS builder-windows

# Set environment variables for Windows
ENV GOARCH=amd64
ENV GOOS=windows

# Set the working directory
WORKDIR /app

# Copy the Go source code
COPY . .

# Build the Windows binary
RUN go build -o 3270Connect.exe go3270Connect.go

#############################
# Final stage for Linux
#############################
FROM alpine:latest AS final-linux

# Copy the Linux binary from the builder
COPY --from=builder-linux /app/3270Connect-linux /usr/local/bin/3270Connect

# Make the binary executable
RUN chmod +x /usr/local/bin/3270Connect

# Define the entrypoint for the Linux container
ENTRYPOINT ["/usr/local/bin/3270Connect"]

#############################
# Final stage for Windows
#############################
FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS final-windows

# Copy the Windows binary from the builder
COPY --from=builder-windows /app/3270Connect.exe C:\3270Connect.exe

# Define the entrypoint for the Windows container
ENTRYPOINT ["C:\\3270Connect.exe"]
7 changes: 7 additions & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Build the Linux image
docker build --target final-linux -t 3270connect-linux .

# Build the Windows image
docker build --target final-windows -t 3270connect-windows .

0 comments on commit 319cb74

Please sign in to comment.