fixed #1368 - correctly generate version number in docker (#1372)

This commit is contained in:
Eugene 2025-06-10 22:08:09 +02:00 committed by GitHub
parent 9e144f826f
commit cafa89f07a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 10 deletions

View file

@ -19,7 +19,6 @@ data
config.*.yaml
config.yaml
.git
warpgate-web/dist
warpgate-web/node_modules
warpgate-web/src/admin/lib/api-client/

View file

@ -37,6 +37,7 @@ jobs:
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@ -64,6 +65,7 @@ jobs:
uses: docker/build-push-action@v6.13.0
with:
file: docker/Dockerfile
context: .
push: false
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.docker-platform }}
@ -75,6 +77,7 @@ jobs:
uses: docker/build-push-action@v6.13.0
with:
file: docker/Dockerfile
context: .
push: true
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.docker-platform }}

View file

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.3-labs
FROM rust:1.79.0-bullseye AS build
FROM rust:1.85.0-bullseye AS build
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get update \
@ -11,17 +11,21 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
COPY . /opt/warpgate
ENV SOURCE_DATE_EPOCH 0 # for rust-embed determinism
# Needed to correctly embed the version number and the dirty state flag
COPY .git/ /opt/warpgate/.git/
# for rust-embed determinism
ENV SOURCE_DATE_EPOCH=0
RUN cd /opt/warpgate \
&& just npm ci \
&& just openapi \
&& just npm run build \
&& cargo build --features mysql,postgres --release
FROM debian:bullseye-20221024
FROM debian:bullseye-20250520
LABEL maintainer=heywoodlh
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN <<EOF
set -xe
apt-get -y update -qq
@ -34,7 +38,7 @@ COPY --from=build /opt/warpgate/target/release/warpgate /usr/local/bin/warpgate
VOLUME /data
ENV DOCKER 1
ENV DOCKER=1
ENTRYPOINT ["warpgate", "--config", "/data/warpgate.yaml"]
CMD ["run"]

View file

@ -349,7 +349,7 @@ def report_generation():
"--all-features",
"--no-report",
"--",
"--version",
"version",
],
cwd=cargo_root,
)

View file

@ -8,12 +8,12 @@ use anyhow::Result;
use clap::{ArgAction, Parser};
use logging::init_logging;
use tracing::*;
use warpgate_common::version::warpgate_version;
use crate::config::load_config;
#[derive(clap::Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
#[clap(author, about, long_about = None)]
pub struct Cli {
#[clap(subcommand)]
command: Commands,
@ -91,6 +91,8 @@ pub(crate) enum Commands {
#[clap(action=ArgAction::Set)]
username: Option<String>,
},
/// Show version information
Version,
}
async fn _main() -> Result<()> {
@ -104,6 +106,10 @@ async fn _main() -> Result<()> {
.unwrap();
match &cli.command {
Commands::Version => {
println!("warpgate {}", warpgate_version());
return Ok(());
}
Commands::Run { enable_admin_token } => {
crate::commands::run::command(&cli, *enable_admin_token).await
}