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
config.yaml config.yaml
.git
warpgate-web/dist warpgate-web/dist
warpgate-web/node_modules warpgate-web/node_modules
warpgate-web/src/admin/lib/api-client/ warpgate-web/src/admin/lib/api-client/

View file

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

View file

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1.3-labs # 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 - \ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get update \ && apt-get update \
@ -11,17 +11,21 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
COPY . /opt/warpgate 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 \ RUN cd /opt/warpgate \
&& just npm ci \ && just npm ci \
&& just openapi \ && just openapi \
&& just npm run build \ && just npm run build \
&& cargo build --features mysql,postgres --release && cargo build --features mysql,postgres --release
FROM debian:bullseye-20221024 FROM debian:bullseye-20250520
LABEL maintainer=heywoodlh LABEL maintainer=heywoodlh
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN <<EOF RUN <<EOF
set -xe set -xe
apt-get -y update -qq apt-get -y update -qq
@ -34,7 +38,7 @@ COPY --from=build /opt/warpgate/target/release/warpgate /usr/local/bin/warpgate
VOLUME /data VOLUME /data
ENV DOCKER 1 ENV DOCKER=1
ENTRYPOINT ["warpgate", "--config", "/data/warpgate.yaml"] ENTRYPOINT ["warpgate", "--config", "/data/warpgate.yaml"]
CMD ["run"] CMD ["run"]

View file

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

View file

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