Ajouter version subcommand
Affiche la version de l'exécutable tel que défini at build time. Autres changements: - [DOCKERFILE] Ajouter `ARG agecem_org_version` - [FEATURE] Ajouter package version/ - [DOCKERFILE] `ADD version/` - [DOCKERFILE] Retirer installsuffix de build step - [DOCKERFILE] Utiliser `agecem_org_version` pour remplir version.version dans l'exécutabe - [DOCKERFILE] Nommer deuxième stage `run` - [DOCKER-COMPOSE] Standardiser valeurs
This commit is contained in:
parent
1c558687b4
commit
6c97a670c6
4 changed files with 52 additions and 10 deletions
12
Dockerfile
12
Dockerfile
|
@ -1,4 +1,6 @@
|
|||
FROM golang:1.21.1 as build
|
||||
FROM golang:1.21.1 AS build
|
||||
|
||||
ARG agecem_org_version
|
||||
|
||||
LABEL author="Victor Lacasse-Beaudoin <vlbeaudoin@agecem.org>"
|
||||
|
||||
|
@ -24,17 +26,17 @@ ADD models/ models/
|
|||
|
||||
ADD templates/ templates/
|
||||
|
||||
ADD version/ version/
|
||||
|
||||
ADD web_handlers/ web_handlers/
|
||||
|
||||
Add webresponse/ webresponse/
|
||||
|
||||
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o agecem-org .
|
||||
RUN CGO_ENABLED=0 go build -a -o agecem-org -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=$agecem_org_version'" .
|
||||
|
||||
# Alpine
|
||||
|
||||
FROM alpine:3.18.3
|
||||
|
||||
WORKDIR /app
|
||||
FROM alpine:3.18.3 AS run
|
||||
|
||||
COPY --from=build /go/src/app/agecem-org /usr/bin/agecem-org
|
||||
|
||||
|
|
21
cmd/version.go
Normal file
21
cmd/version.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.agecem.com/agecem/agecem-org/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// versionCmd represents the version command
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version registered at build time",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("agecem-org", version.Version())
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
services:
|
||||
minio:
|
||||
image: 'quay.io/minio/minio:latest'
|
||||
restart: unless-stopped
|
||||
restart: 'unless-stopped'
|
||||
environment:
|
||||
- "MINIO_ROOT_USER=${MINIO_ROOT_USER}"
|
||||
- "MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}"
|
||||
MINIO_ROOT_USER: "${MINIO_ROOT_USER}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD}"
|
||||
volumes:
|
||||
- 'minio-data:/data'
|
||||
command: 'server /data --console-address ":9001"'
|
||||
server:
|
||||
depends_on:
|
||||
- 'minio'
|
||||
restart: unless-stopped
|
||||
restart: 'unless-stopped'
|
||||
build: .
|
||||
image: git.agecem.com/agecem/agecem-org:latest
|
||||
image: 'git.agecem.com/agecem/agecem-org:latest'
|
||||
ports:
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
|
|
19
version/version.go
Normal file
19
version/version.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package version
|
||||
|
||||
// Filled by build flag
|
||||
var version string
|
||||
|
||||
/*
|
||||
Version returns the application version
|
||||
|
||||
Example command to use the output of `git describe` for version number at build time:
|
||||
|
||||
$ go build -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=`git describe`'" .
|
||||
*/
|
||||
func Version() string {
|
||||
if version == "" {
|
||||
return "version unknown"
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
Loading…
Reference in a new issue