Skip to content

Commit deb57fb

Browse files
committed
feat(Docker): publish an latest-en (english only docker image)
Related to #330
1 parent 2c9db24 commit deb57fb

4 files changed

Lines changed: 39 additions & 11 deletions

File tree

.github/workflows/sharevb-docker-realease-latest.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ jobs:
4141
runs-on: ubuntu-latest
4242
needs:
4343
- ci
44+
strategy:
45+
matrix:
46+
language: ['', 'en']
4447
steps:
4548
- name: Docker meta
4649
id: meta
4750
uses: docker/metadata-action@v6
4851
with:
4952
images: sharevb/it-tools
5053
labels: |
51-
org.opencontainers.image.version=latest
54+
org.opencontainers.image.version=${{ case(matrix.language != '', format('latest-{0}', matrix.language), 'latest') }}
5255
5356
# Checkout the repository
5457
- name: Checkout repository
@@ -80,12 +83,14 @@ jobs:
8083
file: ./Dockerfile
8184
build-args: |
8285
"BASE_URL=/"
86+
"VITE_AVAILABLE_LOCALES=${{ matrix.language }}"
87+
"VITE_LANGUAGE=${{ matrix.language }}"
8388
platforms: linux/amd64,linux/arm64
8489
push: true
8590
labels: ${{ steps.meta.outputs.labels }}
8691
tags: |
87-
sharevb/it-tools:latest
88-
ghcr.io/${{ github.repository_owner }}/it-tools:latest
92+
sharevb/it-tools:${{ case(matrix.language != '', format('latest-{0}', matrix.language), 'latest') }}
93+
ghcr.io/sharevb/it-tools:${{ case(matrix.language != '', format('latest-{0}', matrix.language), 'latest') }}
8994
9095
# Optionally log out
9196
- name: Log out from GitHub Container Registry

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN npm install -g pnpm && pnpm i --ignore-scripts --frozen-lockfile
1313
COPY . .
1414
ARG BASE_URL
1515
ENV BASE_URL=${BASE_URL}
16+
ARG VITE_AVAILABLE_LOCALES
17+
ENV VITE_AVAILABLE_LOCALES=${VITE_AVAILABLE_LOCALES}
1618
ENV VITE_VERCEL_ENV=production
1719
RUN pnpm build
1820

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ Use of WSL2 is recommended to develop using VSCode on Windows. Direct developmen
5858

5959
[Docker Hub](https://hub.docker.com/r/sharevb/it-tools): `sharevb/it-tools:latest`
6060

61+
```bash
62+
docker run --pull always --restart unless-stopped -p 8080:8080 sharevb/it-tools:latest
63+
```
64+
65+
Other existing docker tags: `latest-en` (english only)
66+
6167
## Use in Docker Compose file
6268

6369
```yml

vite.config.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,38 @@ import VueI18n from '@intlify/unplugin-vue-i18n/vite';
2121

2222
const baseUrl = process.env.BASE_URL || '/';
2323

24+
25+
const VITE_AVAILABLE_LOCALES = process.env.VITE_AVAILABLE_LOCALES;
26+
console.log(`Building for locales: ${VITE_AVAILABLE_LOCALES}`);
27+
28+
let includeLocales = [
29+
resolve(__dirname, 'locales/en.yml'),
30+
];
31+
if (!process.env.VITEST) {
32+
if (!VITE_AVAILABLE_LOCALES || VITE_AVAILABLE_LOCALES === '*' || VITE_AVAILABLE_LOCALES === 'all') {
33+
includeLocales = [
34+
resolve(__dirname, 'src/tools/*/locales/**'),
35+
resolve(__dirname, 'locales/**'),
36+
];
37+
} else {
38+
includeLocales = [
39+
resolve(__dirname, 'src/tools/*/locales/{' + VITE_AVAILABLE_LOCALES + '}.*'),
40+
resolve(__dirname, 'locales/{' + VITE_AVAILABLE_LOCALES + '}.*'),
41+
];
42+
}
43+
}
44+
2445
// https://vitejs.dev/config/
2546
export default defineConfig({
2647
plugins: [
2748
VueI18n({
2849
runtimeOnly: true,
2950
compositionOnly: true,
3051
fullInstall: true,
31-
include: !process.env.VITEST
32-
? [
33-
resolve(__dirname, 'src/tools/*/locales/**'),
34-
resolve(__dirname, 'locales/**'),
35-
]
36-
: [
37-
resolve(__dirname, 'locales/en.yml'),
38-
],
52+
include: ,
3953
strictMessage: false,
4054
escapeHtml: true,
55+
onlyLocales: (process.env.VITE_AVAILABLE_LOCALES || '').split(/,/),
4156
}),
4257
AutoImport({
4358
imports: [

0 commit comments

Comments
 (0)