Add dockerfile for standalone webapp only
This commit is contained in:
parent
6939bd6257
commit
09b604fac0
|
@ -0,0 +1,85 @@
|
|||
name: Docker Web
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
buildx:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: get-npm-version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@master
|
||||
|
||||
-
|
||||
name: Prepare
|
||||
id: prepare
|
||||
run: |
|
||||
DOCKER_IMAGE=ttshivers/syncloungeweb
|
||||
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
|
||||
VERSION=latest
|
||||
SOURCE_BRANCH=${GITHUB_REF#refs/heads/}
|
||||
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
fi
|
||||
|
||||
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
|
||||
|
||||
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||
echo ::set-output name=version::${VERSION}
|
||||
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
||||
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||
--build-arg REVISION=${GITHUB_SHA:0:7} \
|
||||
--build-arg SOURCE_BRANCH=${SOURCE_BRANCH} \
|
||||
--build-arg VERSION=${{ steps.package-version.outputs.current-version}} \
|
||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
||||
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
||||
${TAGS} --file ./Dockerfile ./
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v3
|
||||
-
|
||||
name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
id: cache
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
-
|
||||
name: Docker Buildx (build)
|
||||
run: |
|
||||
docker buildx build \
|
||||
--output "type=image,push=false" \
|
||||
${{ steps.prepare.outputs.buildx_args }}
|
||||
-
|
||||
name: Docker Login
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||
-
|
||||
name: Docker Buildx (push)
|
||||
run: |
|
||||
docker buildx build \
|
||||
--output "type=image,push=true" \
|
||||
${{ steps.prepare.outputs.buildx_args }}
|
||||
-
|
||||
name: Docker Check Manifest
|
||||
run: |
|
||||
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
|
||||
-
|
||||
name: Clear
|
||||
if: always()
|
||||
run: |
|
||||
rm -f ${HOME}/.docker/config.json
|
|
@ -0,0 +1,31 @@
|
|||
# build environment
|
||||
FROM --platform=$BUILDPLATFORM node:current-alpine as build-stage
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
|
||||
ARG SOURCE_BRANCH
|
||||
ARG REVISION
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# production environment
|
||||
FROM nginx:alpine as production-stage
|
||||
WORKDIR /app
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
|
||||
ARG VERSION
|
||||
ARG REVISION
|
||||
ARG BUILD_DATE
|
||||
|
||||
LABEL org.opencontainers.image.created=$BUILD_DATE
|
||||
LABEL org.opencontainers.image.title="SyncLounge Web"
|
||||
LABEL org.opencontainers.image.description="Enjoy Plex with your friends. In Sync. Together."
|
||||
LABEL org.opencontainers.image.url="https://synclounge.tv/"
|
||||
LABEL org.opencontainers.image.revision=$REVISION
|
||||
LABEL org.opencontainers.image.source="https://github.com/samcm/synclounge"
|
||||
LABEL org.opencontainers.image.vendor="SyncLounge"
|
||||
LABEL org.opencontainers.image.version=$VERSION
|
||||
LABEL org.opencontainers.image.licenses="MIT"
|
||||
LABEL org.opencontainers.image.documentation="https://docs.synclounge.tv/"
|
Loading…
Reference in New Issue