ci: enable static build with Jenkinsfile and flake.nix
This commit is contained in:
parent
4ad8e03820
commit
33aeba9f1e
27
Dockerfile
27
Dockerfile
|
@ -1,27 +0,0 @@
|
|||
FROM node:18.17.0-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Listening port
|
||||
ARG PORT=3000
|
||||
EXPOSE ${PORT}
|
||||
|
||||
# Credentials
|
||||
ARG SIMPLECAST_ACCESS_TOKEN
|
||||
ARG REVALIDATE_WEBHOOK_TOKEN
|
||||
ARG STRAPI_API_KEY
|
||||
# Strapi URL
|
||||
ARG STRAPI_API_URL
|
||||
ARG STRAPI_GRAPHQL_URL
|
||||
ARG NEXT_PUBLIC_ASSETS_BASE_URL
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV SOURCE_DIR=/app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN NODE_ENV=development yarn install
|
||||
RUN yarn build
|
||||
|
||||
CMD ["yarn", "start"]
|
|
@ -1,37 +1,9 @@
|
|||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.6'
|
||||
library 'status-jenkins-lib@v1.9.4'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
parameters {
|
||||
string(
|
||||
name: 'IMAGE_TAG',
|
||||
defaultValue: params.IMAGE_TAG ?: '',
|
||||
description: 'Optional Docker image tag to push.'
|
||||
)
|
||||
string(
|
||||
name: 'STRAPI_API_URL',
|
||||
description: 'URL of Strapi API',
|
||||
defaultValue: params.STRAPI_API_URL ?: 'https://cms-press.logos.co/api',
|
||||
)
|
||||
string(
|
||||
name: 'STRAPI_GRAPHQL_URL',
|
||||
description: 'URL of Strapi GraphQL API',
|
||||
defaultValue: params.STRAPI_GRAPHQL_URL ?: 'https://cms-press.logos.co/graphql',
|
||||
)
|
||||
string(
|
||||
name: 'NEXT_PUBLIC_ASSETS_BASE_URL',
|
||||
description: 'URL for public assets',
|
||||
defaultValue: params.NEXT_PUBLIC_ASSETS_BASE_URL ?: 'https://cms-press.logos.co',
|
||||
)
|
||||
string(
|
||||
name: 'DOCKER_REGISTRY',
|
||||
description: 'Docker registry ',
|
||||
defaultValue: params.DOCKER_REGISTRY ?: 'harbor.status.im',
|
||||
)
|
||||
}
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
/* manage how many builds we keep */
|
||||
|
@ -42,70 +14,50 @@ pipeline {
|
|||
}
|
||||
|
||||
environment {
|
||||
IMAGE_NAME = 'acid-info-private/logos-press-engine'
|
||||
GIT_COMMITTER_NAME = 'status-im-auto'
|
||||
GIT_COMMITTER_EMAIL = 'auto@status.im'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Install') {
|
||||
steps {
|
||||
script {
|
||||
nix.develop('yarn install')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
script {
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: 'logos-press-engine-unbody-api-token',
|
||||
usernameVariable: 'UNBODY_PROJECT_ID',
|
||||
passwordVariable: 'UNBODY_API_KEY'
|
||||
),
|
||||
string(
|
||||
credentialsId: 'logos-press-engine-simplecast-token',
|
||||
variable: 'SIMPLECAST_ACCESS_TOKEN'
|
||||
),
|
||||
string(
|
||||
credentialsId: 'logos-press-engine-webhook-token',
|
||||
variable: 'REVALIDATE_WEBHOOK_TOKEN'
|
||||
),
|
||||
string(
|
||||
credentialsId: 'logos-press-engine-strapi-api-key',
|
||||
variable: 'STRAPI_API_KEY'
|
||||
),
|
||||
]) {
|
||||
image = docker.build(
|
||||
"${DOCKER_REGISTRY}/${IMAGE_NAME}:${GIT_COMMIT.take(8)}",
|
||||
["--build-arg='STRAPI_API_KEY=${env.UNBODY_PROJECT_ID}'",
|
||||
"--build-arg='UNBODY_API_KEY=${env.UNBODY_API_KEY}'",
|
||||
"--build-arg='SIMPLECAST_ACCESS_TOKEN=${SIMPLECAST_ACCESS_TOKEN}'",
|
||||
"--build-arg='REVALIDATE_WEBHOOK_TOKEN=${REVALIDATE_WEBHOOK_TOKEN}'",
|
||||
"--build-arg='STRAPI_API_URL=${params.STRAPI_API_URL}'",
|
||||
"--build-arg='STRAPI_GRAPHQL_URL=${params.STRAPI_GRAPHQL_URL}'",
|
||||
"--build-arg='NEXT_PUBLIC_ASSETS_BASE_URL=${params.NEXT_PUBLIC_ASSETS_BASE_URL}'",
|
||||
"--build-arg='STRAPI_API_KEY=${STRAPI_API_KEY}'",
|
||||
"."].join(' ')
|
||||
nix.develop('yarn build')
|
||||
jenkins.genBuildMetaJSON('build/build.json')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Publish') {
|
||||
steps {
|
||||
sshagent(credentials: ['status-im-auto-ssh']) {
|
||||
script {
|
||||
nix.develop("""
|
||||
ghp-import \
|
||||
-b ${deployBranch()} \
|
||||
-c ${deployDomain()} \
|
||||
-p build
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
when { expression { params.IMAGE_TAG != '' } }
|
||||
steps { script {
|
||||
withDockerRegistry([
|
||||
credentialsId: 'harbor-acid-info-private-robot', url: 'https://${DOCKER_REGISTRY}'
|
||||
]) {
|
||||
image.push(params.IMAGE_TAG)
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
cleanup { cleanWs() }
|
||||
always { script {
|
||||
def result = currentBuild.result.toLowerCase() ?: 'unknown'
|
||||
discord.send(
|
||||
header: "Logos Press Engine Docker image build ${result}!",
|
||||
descPrefix: "Image: [`${env.IMAGE_NAME}:${params.IMAGE_TAG}`](https://harbor.status.im/${params.IMAGE_NAME}/tags?name=${params.IMAGE_TAG})",
|
||||
cred: 'logos-press-engine-discord-webhook-url',
|
||||
)
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
|
||||
def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
|
||||
def deployDomain() { isMasterBranch() ? 'press.logos.co' : 'dev-press.logos.co' }
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1721548954,
|
||||
"narHash": "sha256-7cCC8+Tdq1+3OPyc3+gVo9dzUNkNIQfwSDJ2HSi2u3o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "63d37ccd2d178d54e7fb691d7ec76000740ea24a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-24.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forEachSystem = nixpkgs.lib.genAttrs supportedSystems;
|
||||
pkgsFor = forEachSystem (system: import nixpkgs { inherit system; });
|
||||
in
|
||||
rec {
|
||||
formatter = forEachSystem (system: pkgsFor.${system}.nixpkgs-fmt);
|
||||
|
||||
devShells = forEachSystem (system: {
|
||||
default = pkgsFor.${system}.mkShellNoCC {
|
||||
packages = with pkgsFor.${system}.buildPackages; [
|
||||
yarn # 1.22.22
|
||||
nodejs_20 # v20.15.1
|
||||
ghp-import # 2.1.0
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
output: 'export',
|
||||
trailingSlash: true,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
images: {
|
||||
domains: [
|
||||
'localhost',
|
||||
|
|
Loading…
Reference in New Issue