Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Use production Vue builds in released docker image
Jade Ellisf6d99ddef158
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymlindex 0300ba99..7966c3dc 100644--- a/.github/workflows/docker-publish.yml+++ b/.github/workflows/docker-publish.yml@@ -70,3 +70,5 @@ jobs:labels: ${{ steps.meta.outputs.labels }}cache-from: type=ghacache-to: type=gha,mode=max+ build-args: |+ PRODUCTION=1diff --git a/Dockerfile b/Dockerfileindex cae493fa..c8f287e0 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,5 +1,8 @@FROM python:3.11-slim+# Build argument to determine if this is a production build+ARG PRODUCTION=0+WORKDIR /app# Install system dependencies@@ -21,7 +24,7 @@ COPY scripts/download_offline_deps.py scripts/# Install requests and download vendor dependencies BEFORE copying all code# This allows better Docker layer caching - vendor deps won't re-download on code changesRUN pip install --no-cache-dir requests && \- python scripts/download_offline_deps.py && \+ PRODUCTION=${PRODUCTION} python scripts/download_offline_deps.py && \echo "✓ Vendor dependencies downloaded successfully"# Now copy the rest of the application codediff --git a/scripts/download_offline_deps.py b/scripts/download_offline_deps.pyindex 3a5cb376..67c81cdd 100644--- a/scripts/download_offline_deps.py+++ b/scripts/download_offline_deps.py@@ -18,8 +18,7 @@ DEPENDENCIES = {},"js": {"tailwind.min.js": "https://cdn.tailwindcss.com/3.4.0",- "vue.global.js": "https://unpkg.com/vue@3/dist/vue.global.js",- "vue.global.prod.js": "https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js",+ "vue.global.js": "https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js","marked.min.js": "https://cdn.jsdelivr.net/npm/marked/marked.min.js","easymde.min.js": "https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js","axios.min.js": "https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js",@@ -44,10 +43,10 @@ def download_file(url, filepath):try:response = requests.get(url, timeout=30)response.raise_for_status()-+# Create directory if it doesn't existfilepath.parent.mkdir(parents=True, exist_ok=True)-+# Write filewith open(filepath, 'wb') as f:f.write(response.content)@@ -61,27 +60,37 @@ def main():print("Downloading offline dependencies...")print(f"Vendor directory: {VENDOR_DIR}")+ # Check if we're in production mode+ is_production = os.environ.get('FLASK_ENV') == 'production' or os.environ.get('PRODUCTION') == '1'++ if is_production:+ print("⚙️ PRODUCTION MODE: Using production builds")+ # Replace Vue.js development build with production build+ DEPENDENCIES['js']['vue.global.js'] = "https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"+ else:+ print("⚙️ DEVELOPMENT MODE: Using development builds")+# Download CSS and JS filesfor file_type, files in DEPENDENCIES.items():print(f"\n{file_type.upper()} Files:")for filename, url in files.items():filepath = VENDOR_DIR / file_type / filenamedownload_file(url, filepath)-+# Download Font Awesome fontsprint("\nFont Awesome Webfonts:")for url in FONTAWESOME_FONTS:filename = url.split("/")[-1]filepath = VENDOR_DIR / "fonts" / "webfonts" / filenamedownload_file(url, filepath)-+# Update Font Awesome CSS to use local fontsfa_css_path = VENDOR_DIR / "css" / "fontawesome.min.css"if fa_css_path.exists():print("\nUpdating Font Awesome CSS to use local fonts...")with open(fa_css_path, 'r') as f:content = f.read()-+# Replace CDN URLs with local paths - handle both relative and absolute URLscontent = content.replace("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/webfonts/",@@ -96,12 +105,12 @@ def main():"./webfonts/","../fonts/webfonts/")-+with open(fa_css_path, 'w') as f:f.write(content)print(" ✓ Updated Font Awesome CSS paths")-+print("\n✅ All dependencies downloaded successfully!")if __name__ == "__main__":- main()\ No newline at end of file+ main()diff --git a/templates/share.html b/templates/share.htmlindex c58a2172..2227dc62 100644--- a/templates/share.html+++ b/templates/share.html@@ -9,7 +9,7 @@<script src="{{ url_for('static', filename='vendor/js/tailwind.min.js') }}"></script><link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}"><!-- All dependencies bundled locally for offline support -->-<script src="{{ url_for('static', filename='vendor/js/vue.global.prod.js') }}"></script>+<script src="{{ url_for('static', filename='vendor/js/vue.global.js') }}"></script><!-- All dependencies bundled locally for offline support --><script src="{{ url_for('static', filename='vendor/js/axios.min.js') }}"></script><!-- All dependencies bundled locally for offline support -->@@ -35,7 +35,7 @@}}}-+// Function to apply the theme based on localStorage and system preferencefunction applyTheme() {// Guard against early execution@@ -118,32 +118,32 @@<div class="bg-[var(--bg-tertiary)] border-b border-[var(--border-primary)] flex-shrink-0"><div class="max-w-4xl mx-auto"><div class="flex">- <button @click="activeTab = 'transcription'"+ <button @click="activeTab = 'transcription'":class="['flex-1 px-4 py-3 text-sm font-medium transition-colors',- activeTab === 'transcription'- ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]'+ activeTab === 'transcription'+ ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]': 'text-[var(--text-muted)] hover:text-[var(--text-secondary)]']"><i class="fas fa-file-text mr-2"></i>Transcription</button>{% if recording.summary %}- <button @click="activeTab = 'summary'"+ <button @click="activeTab = 'summary'":class="['flex-1 px-4 py-3 text-sm font-medium transition-colors',- activeTab === 'summary'- ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]'+ activeTab === 'summary'+ ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]': 'text-[var(--text-muted)] hover:text-[var(--text-secondary)]']"><i class="fas fa-file-alt mr-2"></i>Summary</button>{% endif %}{% if recording.notes %}- <button @click="activeTab = 'notes'"+ <button @click="activeTab = 'notes'":class="['flex-1 px-4 py-3 text-sm font-medium transition-colors',- activeTab === 'notes'- ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]'+ activeTab === 'notes'+ ? 'bg-[var(--bg-secondary)] text-[var(--text-accent)] border-b-2 border-[var(--border-focus)]': 'text-[var(--text-muted)] hover:text-[var(--text-secondary)]']"><i class="fas fa-sticky-note mr-2"></i>Notes@@ -161,11 +161,11 @@<!-- Transcription Controls --><div class="flex items-center justify-between mb-4 flex-shrink-0"><div v-if="processedTranscription.hasDialogue" class="view-mode-toggle">- <button @click="transcriptView = 'simple'"+ <button @click="transcriptView = 'simple'":class="['toggle-button', transcriptView === 'simple' ? 'active' : '']"><i class="fas fa-list mr-1"></i>Simple</button>- <button @click="transcriptView = 'bubble'"+ <button @click="transcriptView = 'bubble'":class="['toggle-button', transcriptView === 'bubble' ? 'active' : '']"><i class="fas fa-comments mr-1"></i>Bubble</button>@@ -176,7 +176,7 @@</div><!-- Speaker Legend (only for bubble view) -->- <div v-if="processedTranscription.hasDialogue && processedTranscription.speakers.length > 0 && transcriptView === 'bubble'"+ <div v-if="processedTranscription.hasDialogue && processedTranscription.speakers.length > 0 && transcriptView === 'bubble'":class="['speaker-legend', legendExpanded ? 'expanded' : '', 'flex-shrink-0', 'mb-4']"><div class="speaker-legend-header" @click="legendExpanded = !legendExpanded"><div class="speaker-legend-title">@@ -187,8 +187,8 @@<i class="fas fa-chevron-down speaker-legend-toggle"></i></div><div class="speaker-legend-content">- <div v-for="(speaker, index) in processedTranscription.speakers"- :key="index"+ <div v-for="(speaker, index) in processedTranscription.speakers"+ :key="index":class="['speaker-legend-item', speaker.color]"><span class="speaker-name">${speaker.name}</span></div>@@ -199,9 +199,9 @@<div class="w-full flex-1 overflow-y-auto transcription-box" @click="handleTranscriptClick"><!-- Simple View --><div v-if="transcriptView === 'simple'" class="transcription-simple-view">- <div v-for="segment in processedTranscription.simpleSegments"- :key="segment.startTime || Math.random()"- class="speaker-segment cursor-pointer hover:bg-[var(--bg-accent-hover)] p-2 rounded transition-colors mb-2"+ <div v-for="segment in processedTranscription.simpleSegments"+ :key="segment.startTime || Math.random()"+ class="speaker-segment cursor-pointer hover:bg-[var(--bg-accent-hover)] p-2 rounded transition-colors mb-2":data-start-time="segment.startTime"@click="seekAudio(segment.startTime)"style="margin-bottom: 0.5rem !important;">@@ -213,15 +213,15 @@</div></div></div>-+<!-- Bubble View --><div v-else-if="transcriptView === 'bubble'" class="transcription-with-speakers">- <div v-for="(row, rowIndex) in processedTranscription.bubbleRows"- :key="rowIndex"+ <div v-for="(row, rowIndex) in processedTranscription.bubbleRows"+ :key="rowIndex":class="['bubble-row', row.isMe ? 'speaker-me' : '']">- <div v-for="bubble in row.bubbles"- :key="bubble.startTime || Math.random()"- :class="['speaker-bubble', bubble.color, row.isMe ? 'speaker-me' : '', 'cursor-pointer']"+ <div v-for="bubble in row.bubbles"+ :key="bubble.startTime || Math.random()"+ :class="['speaker-bubble', bubble.color, row.isMe ? 'speaker-me' : '', 'cursor-pointer']":data-start-time="bubble.startTime"@click="seekAudio(bubble.startTime)"><div class="speaker-bubble-content">@@ -230,7 +230,7 @@</div></div></div>-+<!-- Plain Text View (for non-JSON transcriptions) --><div v-if="!processedTranscription.isJson" class="whitespace-pre-wrap cursor-pointer hover:bg-[var(--bg-accent-hover)] p-2 rounded transition-colors">${processedTranscription.content}@@ -279,8 +279,8 @@</div><div class="flex items-center gap-2"><span class="text-xs">Built with</span>- <a href="https://github.com/murtaza-nasir/speakr"- target="_blank"+ <a href="https://github.com/murtaza-nasir/speakr"+ target="_blank"rel="noopener noreferrer"class="inline-flex items-center gap-1 text-[var(--text-accent)] hover:text-[var(--text-primary)] transition-colors font-medium"><i class="fab fa-github text-sm"></i>@@ -340,7 +340,7 @@bubbleRows: []};}-+const speakers = [...new Set(transcriptionData.map(segment => segment.speaker).filter(Boolean))];const speakerColors = {};speakers.forEach((speaker, index) => {@@ -464,13 +464,13 @@function toggleDarkMode() {const newDarkMode = !isDarkMode.value;isDarkMode.value = newDarkMode;-+if (newDarkMode) {document.documentElement.classList.add('dark');} else {document.documentElement.classList.remove('dark');}-+localStorage.setItem('darkMode', newDarkMode.toString());}@@ -523,7 +523,7 @@};}});-+app.config.compilerOptions.delimiters = ['${', '}'];app.mount('#app');