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
f69d63c4
Commit
f69d63c4
authored
Sep 16, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deploy refactoring
parent
daf2b2c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
9 deletions
+16
-9
.env.template
.env.template
+0
-0
Dockerfile
Dockerfile
+7
-3
entrypoint.sh
deploy/scripts/entrypoint.sh
+6
-0
replace_envs.sh
deploy/scripts/replace_envs.sh
+3
-6
No files found.
.env.
production
→
.env.
template
View file @
f69d63c4
File moved
Dockerfile
View file @
f69d63c4
...
@@ -13,6 +13,7 @@ FROM node:16-alpine AS builder
...
@@ -13,6 +13,7 @@ FROM node:16-alpine AS builder
WORKDIR
/app
WORKDIR
/app
COPY
--from=deps /app/node_modules ./node_modules
COPY
--from=deps /app/node_modules ./node_modules
COPY
. .
COPY
. .
COPY
.env.template .env.production
# Next.js collects completely anonymous telemetry data about general usage.
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Learn more here: https://nextjs.org/telemetry
...
@@ -41,9 +42,10 @@ COPY --from=builder /app/next.config.js ./
...
@@ -41,9 +42,10 @@ COPY --from=builder /app/next.config.js ./
COPY
--from=builder /app/public ./public
COPY
--from=builder /app/public ./public
COPY
--from=builder /app/package.json ./package.json
COPY
--from=builder /app/package.json ./package.json
# Copy script and ENV templates file
# Copy scripts and ENV templates file
COPY
entrypoint.sh .
COPY
./deploy/scripts/entrypoint.sh .
COPY
.env.production .
COPY
./deploy/scripts/replace_envs.sh .
COPY
.env.template .
# Automatically leverage output traces to reduce image size
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
# https://nextjs.org/docs/advanced-features/output-file-tracing
...
@@ -53,6 +55,8 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
...
@@ -53,6 +55,8 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Execute script for replace build ENV with run ones
# Execute script for replace build ENV with run ones
RUN
apk add
--no-cache
--upgrade
bash
RUN
apk add
--no-cache
--upgrade
bash
RUN
[
"chmod"
,
"+x"
,
"./entrypoint.sh"
]
RUN
[
"chmod"
,
"+x"
,
"./entrypoint.sh"
]
RUN
[
"chmod"
,
"+x"
,
"./replace_envs.sh"
]
ENTRYPOINT
["./entrypoint.sh"]
ENTRYPOINT
["./entrypoint.sh"]
USER
nextjs
USER
nextjs
...
...
deploy/scripts/entrypoint.sh
0 → 100755
View file @
f69d63c4
#!/bin/bash
./replace_envs.sh
echo
"starting Nextjs"
exec
"
$@
"
\ No newline at end of file
entrypoint
.sh
→
deploy/scripts/replace_envs
.sh
100755 → 100644
View file @
f69d63c4
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
set
+x
set
+x
# config
# config
envFilename
=
'.env.
production
'
envFilename
=
'.env.
template
'
nextFolder
=
'./.next/'
nextFolder
=
'./.next/'
# replacing build-stage ENVs with run-stage ENVs
# replacing build-stage ENVs with run-stage ENVs
# https://raphaelpralat.medium.com/system-environment-variables-in-next-js-with-docker-1f0754e04cde
# https://raphaelpralat.medium.com/system-environment-variables-in-next-js-with-docker-1f0754e04cde
function
apply_path
{
function
replace_envs
{
# read all config file
# read all config file
while
read
line
;
do
while
read
line
;
do
# no comment or not empty
# no comment or not empty
...
@@ -31,7 +31,4 @@ function apply_path {
...
@@ -31,7 +31,4 @@ function apply_path {
done
<
$envFilename
done
<
$envFilename
}
}
apply_path
replace_envs
\ No newline at end of file
echo
"Starting Nextjs"
exec
"
$@
"
\ No newline at end of file
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