Docker Issue

I am new to working with this service and have been attempting to add new React components to my site but the new pushes I made triggered a backend issue I don't really understand. I would love some guidance in trying to fix this issue
Solution:
give this a try - ```toml https://nixpacks.com/docs/configuration/file set up some variables to minimize annoyance...
Jump to solution
20 Replies
Percy
Percy7mo ago
Project ID: ef987635-943c-471b-b185-cb7fa26305dc
JackManning
JackManningOP7mo ago
project ID: ef987635-943c-471b-b185-cb7fa26305dc
Brody
Brody7mo ago
what issue are you running into
JackManning
JackManningOP7mo ago
I just tried setting up a router using react-router-dom and it gave me an issue regarding the dockerfile for some reason These are the build logs
Brody
Brody7mo ago
everything is built with a Dockerfile. please send me your nixpacks.toml file
JackManning
JackManningOP7mo ago
https://nixpacks.com/docs/configuration/file set up some variables to minimize annoyance [variables] NPM_CONFIG_UPDATE_NOTIFIER = 'false' # the update notification is relatively useless in a production environment NPM_CONFIG_FUND = 'false' # the fund notification is also pretty useless in a production environment CADDY_VERSION = '2.7.5' # specify the caddy version to use here, without a 'v' prefix. https://github.com/caddyserver/caddy/releases download and untar caddy [phases.caddy] dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase cmds = [ 'curl -fsSLo caddy.tar.gz "https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz"', # download the caddy release specified by 'CADDY_VERSION' from GitHub 'tar -zxvf caddy.tar.gz caddy', # only extract 'caddy' from the tarball 'chmod +x caddy' # enable file execution for caddy, needed to execute downloaded files ] format the Caddyfile with fmt [phases.fmt] dependsOn = ['caddy'] # make sure this phase runs after the 'caddy' phase so that we know we have caddy downloaded cmds = ['caddy fmt --overwrite Caddyfile'] # format the Caddyfile to fix any formatting inconsistencies copy caddy and build artifacts to a new image and start the caddy web server [start] runImage = 'ubuntu:20.04' # use a new ubuntu image to run the caddy server in onlyIncludeFiles = ['caddy', 'Caddyfile', 'build'] # copy only the needed files and folders into the new image (react-scripts builds to a 'build' folder) cmd = './caddy run --config Caddyfile --adapter caddyfile 2>&1' # start caddy using the Caddyfile config and caddyfile adapter
Configuration File Reference | Nixpacks
App source + Nix packages + Docker = Image
GitHub
Releases · caddyserver/caddy
Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS - caddyserver/caddy
Brody
Brody7mo ago
attach it as a file please
JackManning
JackManningOP7mo ago
Brody
Brody7mo ago
have you tried another build?
JackManning
JackManningOP7mo ago
With that nixpacks file? yes
Brody
Brody7mo ago
okay I'll modify it to not download caddy from GitHub when I'm back on my computer
Solution
Brody
Brody7mo ago
give this a try -
# https://nixpacks.com/docs/configuration/file

# set up some variables to minimize annoyance
[variables]
NPM_CONFIG_UPDATE_NOTIFIER = 'false' # the update notification is relatively useless in a production environment
NPM_CONFIG_FUND = 'false' # the fund notification is also pretty useless in a production environment

# download caddy
[phases.caddy]
dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase
nixpkgsArchive = '24b73ab8f29899e829a62e8b64e160a688ef3356' # caddy v2.7.6 - https://github.com/NixOS/nixpkgs/commit/24b73ab8f29899e829a62e8b64e160a688ef3356
nixPkgs = ['caddy']

# format the Caddyfile with fmt
[phases.fmt]
dependsOn = ['caddy'] # make sure this phase runs after the 'caddy' phase so that we know we have caddy downloaded
cmds = ['caddy fmt --overwrite Caddyfile'] # format the Caddyfile to fix any formatting inconsistencies

# start the caddy web server
[start]
cmd = 'caddy run --config Caddyfile --adapter caddyfile 2>&1' # start caddy using the Caddyfile config and caddyfile adapter
# https://nixpacks.com/docs/configuration/file

# set up some variables to minimize annoyance
[variables]
NPM_CONFIG_UPDATE_NOTIFIER = 'false' # the update notification is relatively useless in a production environment
NPM_CONFIG_FUND = 'false' # the fund notification is also pretty useless in a production environment

# download caddy
[phases.caddy]
dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase
nixpkgsArchive = '24b73ab8f29899e829a62e8b64e160a688ef3356' # caddy v2.7.6 - https://github.com/NixOS/nixpkgs/commit/24b73ab8f29899e829a62e8b64e160a688ef3356
nixPkgs = ['caddy']

# format the Caddyfile with fmt
[phases.fmt]
dependsOn = ['caddy'] # make sure this phase runs after the 'caddy' phase so that we know we have caddy downloaded
cmds = ['caddy fmt --overwrite Caddyfile'] # format the Caddyfile to fix any formatting inconsistencies

# start the caddy web server
[start]
cmd = 'caddy run --config Caddyfile --adapter caddyfile 2>&1' # start caddy using the Caddyfile config and caddyfile adapter
JackManning
JackManningOP7mo ago
The build failed again but this time it flagged "Switch" from react-router-dom as not importing correctly. Is there a different router system that you know of that works?
Brody
Brody7mo ago
what version of node do you use locally
JackManning
JackManningOP7mo ago
v18.16.1
Brody
Brody7mo ago
can you run npm run build locally?
JackManning
JackManningOP7mo ago
no locally I'm getting the same error so I guess it must be something wrong with react-router-dom same Switch import bug
Brody
Brody7mo ago
yep not a platform issue for sure
JackManning
JackManningOP7mo ago
My bad for the confusion. Thanks for the help regardless!
Brody
Brody7mo ago
happy to help
Want results from more Discord servers?
Add your server