Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try fixing workflow #30

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# *****************************
# *** STAGE 1: Dependencies ***
# *****************************
FROM node:22.11.0-alpine AS deps
FROM node:20.11.0-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat python3 make g++
RUN ln -sf /usr/bin/python3 /usr/bin/python
Expand Down Expand Up @@ -37,7 +37,7 @@ RUN yarn --frozen-lockfile
# *****************************
# ****** STAGE 2: Build *******
# *****************************
FROM node:22.11.0-alpine AS builder
FROM node:20.11.0-alpine AS builder
RUN apk add --no-cache --upgrade libc6-compat bash

# pass build args to env variables
Expand Down Expand Up @@ -91,7 +91,7 @@ COPY --from=deps /favicon-generator/node_modules ./deploy/tools/favicon-generato
# ******* STAGE 3: Run ********
# *****************************
# Production image, copy all the files and run next
FROM node:22.11.0-alpine AS runner
FROM node:20.11.0-alpine AS runner
RUN apk add --no-cache --upgrade bash curl jq unzip

### APP
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">Blockscout frontend</h1>
<h1 align="center">Blockscout frontend for Autonomy Network</h1>

<p align="center">
<span>Frontend application for </span>
Expand Down
71 changes: 71 additions & 0 deletions deploy/tools/favicon-generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-disable no-console */
const { favicons } = require('favicons');
const fs = require('fs/promises');
const path = require('path');

generateFavicons();

async function generateFavicons() {
console.log('Generating favicons...');
const masterUrl = process.env.MASTER_URL;
try {
if (!masterUrl) {
throw new Error('FAVICON_MASTER_URL or NEXT_PUBLIC_NETWORK_ICON must be set');
}

const fetch = await import('node-fetch');
const response = await fetch.default(masterUrl);
const buffer = await response.arrayBuffer();
const source = Buffer.from(buffer);

const configuration = {
path: '/output',
appName: 'Blockscout',
icons: {
android: true,
appleIcon: {
background: 'transparent',
},
appleStartup: false,
favicons: true,
windows: false,
yandex: false,
},
};

try {
const result = await favicons(source, configuration);

const outputDir = path.resolve(process.cwd(), 'output');
await fs.mkdir(outputDir, { recursive: true });

for (const image of result.images) {
// keep only necessary files
if (image.name === 'apple-touch-icon-180x180.png' || image.name === 'android-chrome-192x192.png' ||
(!image.name.startsWith('apple-touch-icon') && !image.name.startsWith('android-chrome'))
) {
await fs.writeFile(path.join(outputDir, image.name), image.contents);
}

// copy android-chrome-192x192.png to logo-icon.png for marketing purposes
if (image.name === 'android-chrome-192x192.png') {
await fs.writeFile(path.join(outputDir, 'logo-icon.png'), image.contents);
}
}

for (const file of result.files) {
if (file.name !== 'manifest.webmanifest') {
await fs.writeFile(path.join(outputDir, file.name), file.contents);
}
}

console.log('Favicons generated successfully!');
} catch (faviconError) {
console.error('Error generating favicons:', faviconError);
process.exit(1);
}
} catch (error) {
console.error('Error in favicon generation process:', error);
process.exit(1);
}
}
20 changes: 20 additions & 0 deletions deploy/tools/favicon-generator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "favicon-generator",
"version": "1.0.0",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"favicons": "^7.2.0",
"ts-loader": "^9.4.4",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
},
"devDependencies": {
"dotenv-cli": "^7.4.2",
"node-loader": "^2.0.0",
"tsconfig-paths-webpack-plugin": "^4.1.0"
}
}
Loading
Loading