Update version format for canary.

We are now using the traditional versioning format for canary releases, instead of using the commit hash as the version.
This commit is contained in:
Shahrad Elahi 2024-02-12 13:44:07 +03:30
parent b3b9beddf3
commit ccc3b20132
7 changed files with 26 additions and 14 deletions

View File

@ -5,10 +5,16 @@ on:
inputs: inputs:
tag: tag:
description: 'Tag to build' description: 'Tag to build'
required: false required: true
##
# Invoke:
# gh workflow run "Build Prerelease Image" -f tag=2.0.0-canary.0
##
env: env:
IMAGE_TAG: canary-${{ github.event.inputs.tag || github.sha }} IMAGE_TAG: ${{ github.event.inputs.tag }}
BUILD_PLATFORMS: linux/amd64,linux/arm64
permissions: permissions:
contents: read contents: read
@ -38,6 +44,7 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
push: true push: true
args: VERSION=${{ env.IMAGE_TAG }}
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
@ -64,4 +71,6 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
push: true push: true
platforms: ${{ env.BUILD_PLATFORMS }}
args: VERSION=${{ env.IMAGE_TAG }}
tags: docker.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tags: docker.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}

View File

@ -82,6 +82,10 @@ RUN mkdir -p /var/vlogs && touch /var/vlogs/web && chmod -R 600 /var/vlogs
# Volumes # Volumes
VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"] VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"]
# Overwrite package version
ARG VERSION=0.0.0-canary
RUN node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('/app/package.json')); pkg.version = process.env.VERSION; fs.writeFileSync('/app/package.json', JSON.stringify(pkg, null, 2));"
# Run the app # Run the app
EXPOSE 3000/tcp EXPOSE 3000/tcp
CMD [ "npm", "run", "start" ] CMD [ "npm", "run", "start" ]

View File

@ -45,17 +45,20 @@ FROM base AS runner
ENV NODE_ENV=development ENV NODE_ENV=development
ENV LOG_LEVEL=debug ENV LOG_LEVEL=debug
ENV VERSION=0.0.0-dev
COPY docker-entrypoint.sh /entrypoint.sh COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
# Fix permissions
RUN mkdir -p /data && chmod 700 /data RUN mkdir -p /data && chmod 700 /data
RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d RUN mkdir -p /etc/torrc.d && chmod -R 400 /etc/torrc.d
RUN mkdir -p /var/vlogs && touch /var/vlogs/web && chmod -R 600 /var/vlogs RUN mkdir -p /var/vlogs && touch /var/vlogs/web && chmod -R 600 /var/vlogs
# Volumes
VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"] VOLUME ["/etc/torrc.d", "/data", "/var/vlogs"]
# run the app # Run the app
EXPOSE 5173/tcp EXPOSE 5173/tcp
CMD [ "npm", "run", "dev", "--", "--host" ] CMD [ "npm", "run", "dev", "--", "--host" ]

View File

@ -9,7 +9,7 @@ services:
# You can use `openssl rand -base64 8` to generate a secure password # You can use `openssl rand -base64 8` to generate a secure password
- UI_PASSWORD=super-secret-password - UI_PASSWORD=super-secret-password
image: litehex/wireadmin image: wireadmin
container_name: wireadmin container_name: wireadmin
restart: unless-stopped restart: unless-stopped
volumes: volumes:

View File

@ -7,7 +7,7 @@ ENV_FILE="/app/.env"
log() { log() {
local level=$1 local level=$1
local message=$2 local message=$2
echo -e "\n[$(date +"%Y-%m-%d %H:%M:%S")] [$level] $message" echo "[$(date +"%Y-%m-%d %H:%M:%S")] [$level] $message"
} }
to_camel_case() { to_camel_case() {
@ -18,8 +18,6 @@ generate_tor_config() {
# IP address of the container # IP address of the container
local inet_address="$(hostname -i | awk '{print $1}')" local inet_address="$(hostname -i | awk '{print $1}')"
log "notice" "Using the following IP address for the Tor network: $inet_address"
sed -i "s/{{INET_ADDRESS}}/$inet_address/g" "${TOR_CONFIG}" sed -i "s/{{INET_ADDRESS}}/$inet_address/g" "${TOR_CONFIG}"
# any other environment variables that start with TOR_ are added to the torrc # any other environment variables that start with TOR_ are added to the torrc
@ -39,7 +37,10 @@ generate_tor_config() {
# any file in it, adding them to the torrc file # any file in it, adding them to the torrc file
local torrc_files=$(find /etc/torrc.d -type f -name "*.conf") local torrc_files=$(find /etc/torrc.d -type f -name "*.conf")
if [ -n "${torrc_files}" ]; then if [ -n "${torrc_files}" ]; then
log "notice" "Found torrc.d folder with configuration files"
for file in ${torrc_files}; do for file in ${torrc_files}; do
log "notice" "Adding $file to the main torrc file"
cat "$file" >>"${TOR_CONFIG}" cat "$file" >>"${TOR_CONFIG}"
done done
fi fi
@ -96,10 +97,6 @@ fi
awk -F= '!a[$1]++' "${ENV_FILE}" >"/tmp/$(basename "${ENV_FILE}")" && awk -F= '!a[$1]++' "${ENV_FILE}" >"/tmp/$(basename "${ENV_FILE}")" &&
mv "/tmp/$(basename "${ENV_FILE}")" "${ENV_FILE}" mv "/tmp/$(basename "${ENV_FILE}")" "${ENV_FILE}"
# Starting Redis server in detached mode
screen -L -Logfile /var/vlogs/redis -dmS "redis" \
bash -c "redis-server --port 6479 --daemonize no --dir /data --appendonly yes"
# Generate Tor configuration # Generate Tor configuration
generate_tor_config generate_tor_config

View File

@ -1,7 +1,6 @@
{ {
"name": "wireadmin", "name": "wireadmin",
"version": "1.0.0", "version": "0.0.0-dev",
"description": "",
"scripts": { "scripts": {
"dev": "docker compose rm -fsv && docker compose -f docker-compose.yml -f docker-compose.dev.yml up", "dev": "docker compose rm -fsv && docker compose -f docker-compose.yml -f docker-compose.dev.yml up",
"dev:image": "docker buildx build --tag wireadmin -f Dockerfile-Dev .", "dev:image": "docker buildx build --tag wireadmin -f Dockerfile-Dev .",

View File

@ -1,6 +1,6 @@
{ {
"name": "web", "name": "web",
"version": "1.1.2", "version": "0.0.0-dev",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",