Last active
February 22, 2022 14:42
-
-
Save vinicius73/c48471a7c1a366a1bb17ba84c4f50f29 to your computer and use it in GitHub Desktop.
Vue Caddy server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
dist | |
infra | |
.tmp | |
# Yarn | |
.pnp.* | |
.yarn/* | |
!.yarn/patches | |
!.yarn/plugins | |
!.yarn/releases | |
!.yarn/sdks | |
!.yarn/versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
admin off | |
log { | |
format json | |
} | |
} | |
:80 { | |
try_files {path} / | |
header /assets/img/* Cache-Control max-age=31536000 | |
header /assets/js/* Cache-Control max-age=31536000 | |
header /assets/css/* Cache-Control max-age=31536000 | |
header /assets/fonts/* Cache-Control max-age=31536000 | |
encode gzip | |
root * /usr/share/caddy | |
file_server { | |
precompressed zstd br gzip | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:16-alpine as builder | |
WORKDIR /app | |
# dependencies | |
COPY ./package.* ./yarn.* /app/ | |
RUN yarn install | |
# build | |
COPY ./ /app/ | |
RUN yarn build | |
FROM caddy:2.4.6-alpine | |
COPY --from=builder /app/dist /usr/share/caddy | |
COPY Caddyfile /etc/caddy/Caddyfile | |
EXPOSE 80 | |
ARG APP_VERSION=unknown | |
ARG GIT_HASH=unknown | |
ARG BUILDER=unknown | |
ARG BUILD_NUMBER=unknown | |
ARG BUILD_DATE=unknown | |
# Labels. | |
LABEL name="app-name" \ | |
description="app description" \ | |
vcs.url="https://bitbucket.org/org/repo-name" \ | |
vcs.ref=$GIT_HASH \ | |
version=$APP_VERSION \ | |
build.date=$BUILD_DATE \ | |
build.number=$BUILD_NUMBER \ | |
build.builder=$BUILDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
APP_VERSION=${BITBUCKET_TAG} | |
BUILD_NUMBER=${BITBUCKET_BUILD_NUMBER:=unknown} | |
BUILDER=${USER}@$(hostname 2> /dev/null && echo $? | tail -0 || echo '@ci') | |
BUILD_DATE=$(date '+%Y-%m-%d__%H:%M:%S') | |
COMMIT=$(git rev-parse HEAD 2> /dev/null && echo $? | tail -0 || echo "$BITBUCKET_COMMIT") | |
BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null && echo $? | tail -0 || echo '') | |
if [ -z "$APP_VERSION" ] | |
then | |
APP_VERSION=$(node -p "require('./package.json').version" 2> /dev/null && echo $? | tail -0 || echo "$BUILD_NUMBER@$BUILD_DATE") | |
fi | |
if [ -z "$BRANCH" ] | |
then | |
BRANCH=${BITBUCKET_TAG:=$BITBUCKET_BRANCH} | |
fi | |
if [ -z "$DOCKER_BUILDKIT" ] | |
then | |
if [ -z "$CI" ] | |
then | |
DOCKER_BUILDKIT=1 | |
fi | |
fi | |
GIT_HASH=${BRANCH}@${COMMIT} | |
echo '@> Building edge image...' | |
echo "@=> APP_VERSION=${APP_VERSION}" | |
echo "@=> GIT_HASH=${GIT_HASH}" | |
echo "@=> BUILDER=${BUILDER}" | |
echo "@=> BUILD_DATE=${BUILD_DATE}" | |
echo "@=> BUILD_NUMBER=${BUILD_NUMBER}" | |
echo "@=> DOCKER_BUILDKIT=${DOCKER_BUILDKIT}" | |
echo '' | |
DOCKER_BUILDKIT=${DOCKER_BUILDKIT} docker build --progress=plain -t vue-app \ | |
--build-arg APP_VERSION="${APP_VERSION}" \ | |
--build-arg GIT_HASH="${GIT_HASH}" \ | |
--build-arg BUILDER="${BUILDER}" \ | |
--build-arg BUILD_DATE="${BUILD_DATE}" \ | |
--build-arg BUILD_NUMBER=${BUILD_NUMBER} \ | |
. | |
echo '@> Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment