• Stars
    star
    36
  • Rank 710,170 (Top 15 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker image for building Go binaries with MinGW toolchain

go-mingw

Docker Hub Docker Hub

Docker image for building Go binaries for Windows with MinGW-w64 toolchain based on official Go Docker image.

The repository provides simple cross-compilation environment for windows 32 and 64bit builds.

Usage

You can pull Docker image with desired Go version from Docker Hub:

docker pull x1unix/go-mingw:latest # or "1.17" for specific Go version

Recommended: Please take a look at full project build example before starting to work.

Building Go applications inside container

Mount directory with app source and build it:

docker run --rm -it -v /YourPackageSrc:/go/work \
    -w /go/work \
    x1unix/go-mingw go build .

You will get compiled Windows binary.

For 32-bit toolchain

To build a 32-bit executable, set GOARCH=386 variable:

docker run --rm -it -e GOARCH=386 -v /YourPackageSrc:/go/work \
    -w /go/work \
    x1unix/go-mingw go build .

Recommended: See full project build example here.

Go linker flags override

You can override Go linker flags and other flags by specifying environment variable for a container using -e option.

Example:

docker exec -it
    -e LDFLAGS="-linkmode external -extldflags '-static -s -w'"
    ...

Produced files ownership

By default, the container starts as root user. It means, that all produced files will be owned by root:root user.

To set files to be owned by your current user by default, you need to start the container with your current uid/gid.

Use -u flag to start container with different user/group id.

# Start container as other uid/gid
docker exec --rm -it -u "$UID:$GID" ...

Attention: we recommend to mount your host GOPATH and GOCACHE instead of separated volumes approach when using UID/GID other than root.

Go Build Cache

In order to speed up build times and keep Go build cache, you can mount your Go build cache directory or create a separate Docker volume for it.

Local GOPATH

docker run --rm -it \
    -u $UID \
    -v /YourPackageSrc:/go/work \
    -v $(go env GOCACHE):/go/cache \
    -e GOCACHE=/go/cache \
    -w /go/work \
    x1unix/go-mingw go build .

Volume:

# Create Docker volume
docker volume create go-cache

# Run container with attached volume
docker run --rm -it \
    -v /YourPackageSrc:/go/work \
    -v go-cache:/go/cache \
    -e GOCACHE=/go/cache \
    -w /go/work \
    x1unix/go-mingw go build .

See Docker volumes docs for more info.

Go modules cache

In addition to Go build cache, you may also want to mount Go modules cache to avoid modules re-download on each build.

To do this, mount your GOPATH or Go modules directory ($GOPATH/pkg).

Building custom Docker image

You can build image locally with specified Go version:

make image GO_VERSION=1.17

Replace 1.17 with desired Go version.

More Repositories

1

go-playground

๐Ÿ‡บ๐Ÿ‡ฆ Better Go Playground powered by React and Monaco editor
Go
983
star
2

s60-icon-pack

Nokia Series60 Icon Pack For Android
Kotlin
42
star
3

Avi

๐ŸŽฌ Pocket online cinema for Android (Deprecated)
Java
19
star
4

karkas

A tiny template engine based on TypeScript
TypeScript
14
star
5

apache-toolkit

Easy virtual host management for Apache on Linux.
Shell
12
star
6

telshell

Tiny Telnet shell server in Go
Go
12
star
7

plymouth-manager

Tiny theme manager for Plymouth bootsplash
Shell
6
star
8

springboard

Simple and configurable services dashboard
TypeScript
5
star
9

demo-go-plugins

Feed web app as Go plugins demo
Go
4
star
10

moonwalker

PHP Middleware & Grabber For Moonwalk.cc CDN
PHP
4
star
11

menthol

Application-oriented UI framework for the Web
TypeScript
4
star
12

arpscan

ARP Scanner
Go
3
star
13

jsonreflect

JSON reflection for Go (WIP)
Go
3
star
14

megadeck

Custom StreamDeck-like clone using Arduino Pro Micro and RobotDyn keypad
C++
3
star
15

foodcourt

Backend for FoodCourt app (mirror)
Go
3
star
16

AppKit

AppKit is cross-platform application runtime environment that support to create apps using HTML, CSS, JS and AppKit API
C++
3
star
17

x1unix

3
star
18

innosilicon-web-ui

Sources for Innosilicon admin web UI
JavaScript
2
star
19

web-rt

Platform for native web-applications
C#
2
star
20

asm-playground

Assembly
2
star
21

docker-php-micro

Tiny Docker container for PHP development
Dockerfile
2
star
22

Cupertino

MacOS-like top panel with global menu for Windows
C#
2
star
23

go-regwatch

Registry change watcher
Go
2
star
24

sbda-ledger

:shipit: Backend for a social expenses ledger for groups of friends.
Go
2
star
25

urlpreview.js

Fetch data from URL on input field paste
JavaScript
2
star
26

MarbleRun

Simple marble maze game in Unreal Engine
1
star
27

foodcourt-ui

UI part of FoodCourt app (mirror)
TypeScript
1
star
28

GoogleNowSlider

Sliding preloader from Google Now for web sites
CSS
1
star
29

govmomi-playbook

Go
1
star
30

go-wasm-imports-example

Custom WebAssembly imports example in Go
JavaScript
1
star
31

rust-lorem

Lorem ipsum generator in Rust
Rust
1
star
32

cashlytics

Bank transactions analytics app
Kotlin
1
star
33

arduino-demo-ticker

Ticker on Arduino on LED tube display
C++
1
star
34

arduino-distance-detection

Distance measurement and detection project
C++
1
star
35

rubbishball-z

C#
1
star
36

DriverPack-Optimisator

DriverPack Optimisator its part of DriverPack Solution project. This tool called to improve Windows PC performance by using several system tweaks.
JavaScript
1
star
37

ostriv

HTML
1
star
38

foundation

Collection of useful functions and structs for Go projects
Go
1
star
39

docusearch

Simple document upload, management and search toy-service
Go
1
star
40

docker-google-coursebuilder

Google Course Builder Docker image
Python
1
star
41

webgl-learn

Personal practice for WebGL
JavaScript
1
star
42

snake-nx

Simple snake game for Nintendo Switch
C++
1
star
43

android-kotlin-study

Kotlin
1
star
44

open-gears

A lightweight MVC framework for PHP
PHP
1
star
45

pyvmomi-playbook

pyvmomi with examples for ESXi 4.x-5.x
Python
1
star