Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
af59a40b
Commit
af59a40b
authored
Sep 15, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace build envs
parent
669f9673
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
12 deletions
+66
-12
.env.production
.env.production
+6
-0
Dockerfile
Dockerfile
+9
-0
entrypoint.sh
entrypoint.sh
+37
-0
parseNetworkConfig.js
lib/networks/parseNetworkConfig.js
+3
-1
getStaticPaths.ts
lib/next/getStaticPaths.ts
+5
-0
next.config.js
next.config.js
+3
-0
index.tsx
pages/[network_type]/[network_sub_type]/index.tsx
+3
-11
No files found.
.env.production
0 → 100644
View file @
af59a40b
NEXT_PUBLIC_SUPPORTED_NETWORKS=APP_NEXT_NEXT_PUBLIC_SUPPORTED_NETWORKS
NEXT_PUBLIC_BLOCKSCOUT_VERSION=APP_NEXT_NEXT_PUBLIC_BLOCKSCOUT_VERSION
NEXT_PUBLIC_FOOTER_GITHUB_LINK=APP_NEXT_NEXT_PUBLIC_FOOTER_GITHUB_LINK
NEXT_PUBLIC_FOOTER_TWITTER_LINK=APP_NEXT_NEXT_PUBLIC_FOOTER_TWITTER_LINK
NEXT_PUBLIC_FOOTER_TELEGRAM_LINK=APP_NEXT_NEXT_PUBLIC_FOOTER_TELEGRAM_LINK
NEXT_PUBLIC_FOOTER_STAKING_LINK=APP_NEXT_NEXT_PUBLIC_FOOTER_STAKING_LINK
Dockerfile
View file @
af59a40b
...
...
@@ -41,11 +41,20 @@ COPY --from=builder /app/next.config.js ./
COPY
--from=builder /app/public ./public
COPY
--from=builder /app/package.json ./package.json
# Copy script and ENV templates file
COPY
entrypoint.sh .
COPY
.env.production .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY
--from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY
--from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Execute script for replace build ENV with run ones
RUN
apk add
--no-cache
--upgrade
bash
RUN
[
"chmod"
,
"+x"
,
"./entrypoint.sh"
]
ENTRYPOINT
["./entrypoint.sh"]
USER
nextjs
EXPOSE
3000
...
...
entrypoint.sh
0 → 100755
View file @
af59a40b
#!/bin/bash
# no verbose
set
+x
# config
envFilename
=
'.env.production'
nextFolder
=
'./.next/'
# replacing build-stage ENVs with run-stage ENVs
# https://raphaelpralat.medium.com/system-environment-variables-in-next-js-with-docker-1f0754e04cde
function
apply_path
{
# read all config file
while
read
line
;
do
# no comment or not empty
if
[
"
${
line
:0:1
}
"
==
"#"
]
||
[
"
${
line
}
"
==
""
]
;
then
continue
fi
# split
configName
=
"
$(
cut
-d
'='
-f1
<<<
"
$line
"
)
"
configValue
=
"
$(
cut
-d
'='
-f2
<<<
"
$line
"
)
"
# get system env
envValue
=
$(
env
|
grep
"^
$configName
="
|
grep
-oe
'[^=]*$'
)
;
# if config found
if
[
-n
"
$configValue
"
]
&&
[
-n
"
$envValue
"
]
;
then
# replace all
echo
"Replace:
${
configValue
}
with:
${
envValue
}
"
find
$nextFolder
\(
-type
d
-name
.git
-prune
\)
-o
-type
f
-print0
| xargs
-0
sed
-i
"s#
$configValue
#
$envValue
#g"
fi
done
<
$envFilename
}
apply_path
echo
"Starting Nextjs"
exec
"
$@
"
\ No newline at end of file
lib/networks/parseNetworkConfig.js
View file @
af59a40b
const
supportedNetworks
=
process
.
env
.
NEXT_PUBLIC_SUPPORTED_NETWORKS
?.
replaceAll
(
'
\'
'
,
'
"
'
);
// should be CommonJS module since it used for next.config.js
function
parseNetworkConfig
()
{
try
{
return
JSON
.
parse
(
process
.
env
.
NEXT_PUBLIC_SUPPORTED_NETWORKS
||
'
[]
'
);
return
JSON
.
parse
(
supportedNetworks
||
'
[]
'
);
}
catch
(
error
)
{
return
[];
}
...
...
lib/next/getStaticPaths.ts
0 → 100644
View file @
af59a40b
import
type
{
GetStaticPaths
}
from
'
next
'
;
export
const
getStaticPaths
:
GetStaticPaths
=
async
()
=>
{
return
{
paths
:
[],
fallback
:
true
};
};
next.config.js
View file @
af59a40b
...
...
@@ -33,6 +33,9 @@ const moduleExports = {
sentry
:
{
hideSourceMaps
:
true
,
},
publicRuntimeConfig
:
{
NEXT_PUBLIC_SUPPORTED_NETWORKS
:
process
.
env
.
NEXT_PUBLIC_SUPPORTED_NETWORKS
,
},
};
const
sentryWebpackPluginOptions
=
{
...
...
pages/[network_type]/[network_sub_type]/index.tsx
View file @
af59a40b
import
{
VStack
,
Textarea
,
Button
,
Alert
,
AlertTitle
,
AlertDescription
,
Link
,
Code
}
from
'
@chakra-ui/react
'
;
import
type
{
NextPage
,
GetStaticPaths
}
from
'
next
'
;
import
type
{
NextPage
}
from
'
next
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
ChangeEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
...
...
@@ -7,7 +7,6 @@ import React from 'react';
import
*
as
cookies
from
'
lib/cookies
'
;
import
useNetwork
from
'
lib/hooks/useNetwork
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
getAvailablePaths
from
'
lib/networks/getAvailablePaths
'
;
import
Page
from
'
ui/shared/Page
'
;
import
PageHeader
from
'
ui/shared/PageHeader
'
;
...
...
@@ -76,12 +75,5 @@ const Home: NextPage = () => {
export
default
Home
;
export
const
getStaticPaths
:
GetStaticPaths
=
async
()
=>
{
return
{
paths
:
getAvailablePaths
(),
fallback
:
false
};
};
export
const
getStaticProps
=
async
()
=>
{
return
{
props
:
{},
};
};
export
{
getStaticPaths
}
from
'
lib/next/getStaticPaths
'
;
export
{
getStaticProps
}
from
'
lib/next/getStaticProps
'
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment