File: multiple-stage.def

package info (click to toggle)
singularity-container 4.0.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,672 kB
  • sloc: asm: 3,857; sh: 2,125; ansic: 1,677; awk: 414; makefile: 110; python: 99
file content (37 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Bootstrap: docker
From: {{ DEVEL_IMAGE }}
Stage: devel

%arguments
    HOME=/root

%post
  # prep environment
  export PATH="/go/bin:/usr/local/go/bin:$PATH"
  export HOME={{ HOME }}
  cd {{ HOME }}

  # insert source code, could also be copied from the host with %files
  cat << EOF > hello.go
  package main
  import "fmt"

  func main() {
    fmt.Printf("Hello World!\n")
  }
EOF

  go build -o hello hello.go


# Install binary into the final image
Bootstrap: docker
From: {{ FINAL_IMAGE }}
Stage: final

%arguments
    FINAL_IMAGE=alpine:3.17

# install binary from stage one
%files from devel
  {{ HOME }}/hello /bin/hello