mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-12-11 15:55:58 +00:00
build(docker): add docker image files for deployment
This commit is contained in:
parent
aac95deda8
commit
0bfce8c8cf
@ -1,68 +1,68 @@
|
||||
jobs:
|
||||
- job: Build
|
||||
displayName: 'Build'
|
||||
displayName: "Build"
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
vmImage: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
displayName: 'Install Node'
|
||||
displayName: "Install Node"
|
||||
inputs:
|
||||
versionSpec: '12.x'
|
||||
versionSpec: "14.x"
|
||||
|
||||
- task: Cache@2
|
||||
displayName: 'Check Cache'
|
||||
displayName: "Check Cache"
|
||||
inputs:
|
||||
key: 'yarn | yarn.lock'
|
||||
path: 'node_modules'
|
||||
key: "yarn | yarn.lock"
|
||||
path: "node_modules"
|
||||
cacheHitVar: CACHE_RESTORED
|
||||
|
||||
- script: 'yarn install --frozen-lockfile'
|
||||
displayName: 'Install Dependencies'
|
||||
- script: "yarn install --frozen-lockfile"
|
||||
displayName: "Install Dependencies"
|
||||
condition: ne(variables.CACHE_RESTORED, 'true')
|
||||
|
||||
- script: 'yarn build'
|
||||
displayName: 'Build'
|
||||
- script: "yarn build"
|
||||
displayName: "Build"
|
||||
|
||||
- task: PublishPipelineArtifact@1
|
||||
displayName: 'Publish Generated Static Pages as Artifact'
|
||||
displayName: "Publish Generated Static Pages as Artifact"
|
||||
inputs:
|
||||
targetPath: $(System.DefaultWorkingDirectory)/dist
|
||||
artifactName: dist
|
||||
|
||||
- job: BuildDocker
|
||||
displayName: 'Build Docker Images'
|
||||
- job: BuildSsrDocker
|
||||
displayName: "Build Docker Images (SSR)"
|
||||
dependsOn: Build
|
||||
condition: succeeded()
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
vmImage: "ubuntu-latest"
|
||||
|
||||
variables:
|
||||
- name: DOCKER_CLI_EXPERIMENTAL
|
||||
value: 'enabled'
|
||||
value: "enabled"
|
||||
|
||||
- name: Version
|
||||
value: $[replace(variables['Build.SourceBranch'],'refs/tags/v','')]
|
||||
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download Artifact from Build Job'
|
||||
displayName: "Download Artifact from Build Job"
|
||||
inputs:
|
||||
source: current
|
||||
artifact: dist
|
||||
path: $(System.DefaultWorkingDirectory)/dist
|
||||
|
||||
- task: Docker@2
|
||||
displayName: 'Login to Docker Hub'
|
||||
displayName: "Login to Docker Hub"
|
||||
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
||||
inputs:
|
||||
command: login
|
||||
containerRegistry: 'Docker Hub'
|
||||
containerRegistry: "Docker Hub"
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'Register Qemu Binfmt and Docker Buildx Builder'
|
||||
displayName: "Register Qemu Binfmt and Docker Buildx Builder"
|
||||
inputs:
|
||||
script: |
|
||||
docker version
|
||||
@ -70,41 +70,119 @@ jobs:
|
||||
docker buildx create --name builder --driver docker-container
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'Build PR Docker Image'
|
||||
displayName: "Build PR Docker Image"
|
||||
condition: eq(variables['System.PullRequest.TargetBranch'], 'master')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.dev --no-cache \
|
||||
docker buildx build --file ./Dockerfile --no-cache \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag pr-$(System.PullRequest.PullRequestId) .
|
||||
--tag pr-$(System.PullRequest.PullRequestId)-ssr .
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'Build and Push Unstable Docker Image'
|
||||
displayName: "Build and Push Unstable Docker Image"
|
||||
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.dev --no-cache --push \
|
||||
docker buildx build --file ./Dockerfile --no-cache --push \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag jellyfin/jellyfin-vue:unstable-$(Build.BuildNumber) \
|
||||
--tag jellyfin/jellyfin-vue:unstable-ssr-$(Build.BuildNumber) \
|
||||
--tag jellyfin/jellyfin-vue:unstable-ssr \
|
||||
--tag jellyfin/jellyfin-vue:unstable .
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'Build and Push Stable Docker Image'
|
||||
displayName: "Build and Push Stable Docker Image"
|
||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.dev --no-cache --push \
|
||||
docker buildx build --file ./Dockerfile --no-cache --push \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag jellyfin/jellyfin-vue:$(Version) \
|
||||
--tag jellyfin/jellyfin-vue:stable \
|
||||
--tag jellyfin/jellyfin-vue:$(Version)-ssr \
|
||||
--tag jellyfin/jellyfin-vue:stable-ssr \
|
||||
--tag jellyfin/jellyfin-vue:latest .
|
||||
|
||||
- task: Docker@2
|
||||
displayName: 'Logout from Docker Hub'
|
||||
displayName: "Logout from Docker Hub"
|
||||
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
||||
inputs:
|
||||
command: logout
|
||||
containerRegistry: 'Docker Hub'
|
||||
containerRegistry: "Docker Hub"
|
||||
|
||||
- job: BuildDocker
|
||||
displayName: "Build Docker Images"
|
||||
dependsOn: Build
|
||||
condition: succeeded()
|
||||
|
||||
pool:
|
||||
vmImage: "ubuntu-latest"
|
||||
|
||||
variables:
|
||||
- name: DOCKER_CLI_EXPERIMENTAL
|
||||
value: "enabled"
|
||||
|
||||
- name: Version
|
||||
value: $[replace(variables['Build.SourceBranch'],'refs/tags/v','')]
|
||||
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: "Download Artifact from Build Job"
|
||||
inputs:
|
||||
source: current
|
||||
artifact: dist
|
||||
path: $(System.DefaultWorkingDirectory)/dist
|
||||
|
||||
- task: Docker@2
|
||||
displayName: "Login to Docker Hub"
|
||||
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
||||
inputs:
|
||||
command: login
|
||||
containerRegistry: "Docker Hub"
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Register Qemu Binfmt and Docker Buildx Builder"
|
||||
inputs:
|
||||
script: |
|
||||
docker version
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
docker buildx create --name builder --driver docker-container
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Build PR Docker Image"
|
||||
condition: eq(variables['System.PullRequest.TargetBranch'], 'master')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.static --no-cache \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag pr-$(System.PullRequest.PullRequestId)-static .
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Build and Push Unstable Docker Image"
|
||||
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.static --no-cache --push \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag jellyfin/jellyfin-vue:unstable-static-$(Build.BuildNumber) \
|
||||
--tag jellyfin/jellyfin-vue:unstable-static .
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: "Build and Push Stable Docker Image"
|
||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
||||
inputs:
|
||||
script: |
|
||||
docker buildx use --builder builder
|
||||
docker buildx build --file ./Dockerfile.static --no-cache --push \
|
||||
--platform linux/arm,linux/arm64,linux/amd64 \
|
||||
--tag jellyfin/jellyfin-vue:$(Version)-static \
|
||||
--tag jellyfin/jellyfin-vue:stable-static .
|
||||
|
||||
- task: Docker@2
|
||||
displayName: "Logout from Docker Hub"
|
||||
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
||||
inputs:
|
||||
command: logout
|
||||
containerRegistry: "Docker Hub"
|
||||
|
105
.docker/mime.types
Normal file
105
.docker/mime.types
Normal file
@ -0,0 +1,105 @@
|
||||
types {
|
||||
|
||||
# Data interchange
|
||||
|
||||
application/atom+xml atom;
|
||||
application/json json map topojson;
|
||||
application/ld+json jsonld;
|
||||
application/rss+xml rss;
|
||||
# Normalize to standard type.
|
||||
# https://tools.ietf.org/html/rfc7946#section-12
|
||||
application/geo+json geojson;
|
||||
application/xml xml;
|
||||
# Normalize to standard type.
|
||||
# https://tools.ietf.org/html/rfc3870#section-2
|
||||
application/rdf+xml rdf;
|
||||
|
||||
|
||||
# JavaScript
|
||||
|
||||
# Servers should use text/javascript for JavaScript resources.
|
||||
# https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages
|
||||
text/javascript js mjs;
|
||||
application/wasm wasm;
|
||||
|
||||
|
||||
# Manifest files
|
||||
|
||||
application/manifest+json webmanifest;
|
||||
application/x-web-app-manifest+json webapp;
|
||||
text/cache-manifest appcache;
|
||||
|
||||
|
||||
# Media files
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mp4 aac f4a f4b m4a;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg oga ogg opus;
|
||||
audio/wav wav;
|
||||
audi/webm weba;
|
||||
audio/x-realaudio ra;
|
||||
audio/x-matroska mka;
|
||||
image/bmp bmp;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
image/jxr jxr hdp wdp;
|
||||
image/png png;
|
||||
image/svg+xml svg svgz;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/webp webp;
|
||||
image/x-jng jng;
|
||||
video/3gpp 3gp 3gpp;
|
||||
video/mp2t ts;
|
||||
video/mp4 f4p f4v m4v mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/ogg ogv;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asf asx;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
video/x-matroska mkv mk3d;
|
||||
|
||||
# Serving `.ico` image files with a different media type
|
||||
# prevents Internet Explorer from displaying then as images:
|
||||
# https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
|
||||
|
||||
image/x-icon cur ico;
|
||||
|
||||
|
||||
# Subtitles
|
||||
application/subrip sub;
|
||||
text/plain txt ass ssa srt;
|
||||
text/vtt vtt;
|
||||
|
||||
|
||||
# Web fonts
|
||||
|
||||
font/woff woff;
|
||||
font/woff2 woff2;
|
||||
application/vnd.ms-fontobject eot;
|
||||
font/ttf ttf;
|
||||
font/collection ttc;
|
||||
font/otf otf;
|
||||
|
||||
|
||||
# Other
|
||||
|
||||
application/epub+zip epub;
|
||||
application/gzip gz;
|
||||
application/pdf pdf;
|
||||
application/ttml+xml ttml;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-bzip bz;
|
||||
application/x-bzip2 bz2:
|
||||
application/x-mpegURL m3u m3u8;
|
||||
application/x-rar-compressed rar;
|
||||
application/zip zip;
|
||||
text/css css;
|
||||
text/html htm html shtml;
|
||||
|
||||
}
|
19
.docker/nginx.conf
Normal file
19
.docker/nginx.conf
Normal file
@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types application/javascript application/json application/geo+json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/ttml+xml application/xml application/x-mpegURL text/css text/javascript text/plain text/vtt text/xml;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
8
.docker/nuxt.config.js
Normal file
8
.docker/nuxt.config.js
Normal file
@ -0,0 +1,8 @@
|
||||
const config = {
|
||||
server: {
|
||||
port: process.env.PORT || 80,
|
||||
host: process.env.HOST || "0.0.0.0",
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
12
.docker/package.json
Normal file
12
.docker/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "jellyfin-vue",
|
||||
"author": "Jellyfin Team",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "nuxt-start"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt-start": "^2.14.12"
|
||||
}
|
||||
}
|
33
Dockerfile
33
Dockerfile
@ -4,23 +4,30 @@ WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache --virtual .build-deps git python make automake autoconf g++ libpng-dev libtool nasm file
|
||||
|
||||
ADD package.json yarn.lock ./
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
RUN yarn install
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
RUN apk del .build-deps
|
||||
COPY . .
|
||||
|
||||
ADD . .
|
||||
# Build SSR app for production in standalone mode
|
||||
|
||||
RUN yarn build:ssr
|
||||
RUN yarn build:ssr --production --standalone
|
||||
|
||||
# Build final image
|
||||
FROM node:14-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY .docker/package.json .docker/nuxt.config.js ./
|
||||
|
||||
# Copy client files from the build image
|
||||
COPY --from=build /app/.nuxt ./.nuxt
|
||||
COPY --from=build /app/static ./static
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN yarn install --production
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 80
|
||||
|
||||
# set app serving to permissive / assigned
|
||||
ENV NUXT_HOST=0.0.0.0
|
||||
# set app port
|
||||
ENV NUXT_PORT=80
|
||||
|
||||
# start the client
|
||||
CMD [ "yarn", "start:ssr" ]
|
||||
CMD [ "yarn", "start" ]
|
||||
|
@ -1,4 +0,0 @@
|
||||
FROM nginx:alpine
|
||||
COPY dist/ /usr/share/nginx/html/
|
||||
COPY .docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY .docker/mime.types /etc/nginx/mime.types
|
25
Dockerfile.static
Normal file
25
Dockerfile.static
Normal file
@ -0,0 +1,25 @@
|
||||
FROM node:14-alpine AS build
|
||||
|
||||
# Install build dependencies for node modules
|
||||
RUN apk add git python make automake autoconf g++ libpng-dev libtool nasm file
|
||||
|
||||
# Set workdir
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and yarn.lock
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
# Install dependencies
|
||||
RUN yarn install
|
||||
|
||||
# Copy resources
|
||||
COPY . .
|
||||
|
||||
# Build static site
|
||||
RUN yarn build
|
||||
|
||||
# Deploy built distribution to nginx
|
||||
FROM nginx:alpine
|
||||
COPY --from=build /app/dist/ /usr/share/nginx/html/
|
||||
COPY .docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY .docker/mime.types /etc/nginx/mime.types
|
Loading…
Reference in New Issue
Block a user