mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Server: Add Docker image labels (#5158)
This commit is contained in:
parent
3f21a6d9ab
commit
41f01dcc34
@ -74,3 +74,16 @@ ENV RUNNING_IN_DOCKER=1
|
||||
EXPOSE ${APP_PORT}
|
||||
|
||||
CMD [ "npm", "--prefix", "packages/server", "start" ]
|
||||
|
||||
# Build-time metadata
|
||||
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
||||
ARG BUILD_DATE
|
||||
ARG REVISION
|
||||
ARG VERSION
|
||||
LABEL org.opencontainers.image.created="$BUILD_DATE" \
|
||||
org.opencontainers.image.title="Joplin Server" \
|
||||
org.opencontainers.image.description="Docker image for Joplin Server" \
|
||||
org.opencontainers.image.url="https://joplinapp.org/" \
|
||||
org.opencontainers.image.revision="$REVISION" \
|
||||
org.opencontainers.image.source="https://github.com/laurent22/joplin.git" \
|
||||
org.opencontainers.image.version="${VERSION}"
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { execCommand2, rootDir } from './tool-utils';
|
||||
import * as moment from 'moment';
|
||||
|
||||
function getVersionFromTag(tagName: string, isPreRelease: boolean): string {
|
||||
if (tagName.indexOf('server-') !== 0) throw new Error(`Invalid tag: ${tagName}`);
|
||||
@ -18,6 +19,14 @@ async function main() {
|
||||
const tagName = argv.tagName;
|
||||
const isPreRelease = getIsPreRelease(tagName);
|
||||
const imageVersion = getVersionFromTag(tagName, isPreRelease);
|
||||
const buildDate = moment(new Date().getTime()).format('YYYY-MM-DDTHH:mm:ssZ');
|
||||
let revision = '';
|
||||
try {
|
||||
revision = await execCommand2('git rev-parse --short HEAD', { showOutput: false });
|
||||
} catch (error) {
|
||||
console.info('Could not get git commit: metadata revision field will be empty');
|
||||
}
|
||||
const buildArgs = `--build-arg BUILD_DATE="${buildDate}" --build-arg REVISION="${revision}" --build-arg VERSION="${imageVersion}"`;
|
||||
|
||||
process.chdir(rootDir);
|
||||
console.info(`Running from: ${process.cwd()}`);
|
||||
@ -26,7 +35,7 @@ async function main() {
|
||||
console.info('imageVersion:', imageVersion);
|
||||
console.info('isPreRelease:', isPreRelease);
|
||||
|
||||
await execCommand2(`docker build -t "joplin/server:${imageVersion}" -f Dockerfile.server .`);
|
||||
await execCommand2(`docker build -t "joplin/server:${imageVersion}" ${buildArgs} -f Dockerfile.server .`);
|
||||
await execCommand2(`docker push joplin/server:${imageVersion}`);
|
||||
|
||||
if (!isPreRelease) {
|
||||
|
Loading…
Reference in New Issue
Block a user