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
Golang Start Command #748
Comments
Nixpacks currently renders start command as But it should be one of:
|
Currently looking into this issue... this is the change that manages to fix the issue. Though it seemingly breaks how node projects are executed. pub fn get_exec_command(command: &str) -> String {
let params_quote_split = command.split('\"').collect::<Vec<&str>>();
let mut params_space_split = Vec::new();
for (index, arg) in params_quote_split.iter().enumerate() {
let arg = arg.trim();
if arg.is_empty() {
continue;
}
if index % 2 == 0 {
let mut split = arg.split_ascii_whitespace().collect::<Vec<&str>>();
params_space_split.append(&mut split);
} else {
params_space_split.push(arg);
}
}
format!("CMD {params_space_split:?}")
} This will change the format to... |
Looking a bit deeper... FROM node:18
WORKDIR /app
COPY ./package.json ./
RUN npm install
COPY . .
# this causes the CMD to not execute correctly
ENTRYPOINT [ "/bin/bash", "-c"]
CMD ["npm", "run", "start"] Defining this entry point causes the This entrypoint is set if nixpacks detects a Node project, but it is not set when it detects something like golang. Resulting in the failure of node projects to start, but not other projects. |
Comparing the dockerfile that is generated for node and golang show why there is an entrypoint difference. GOLANG: run inside ubuntu:jammy, which doesn't have an entrypoint.FROM ghcr.io/railwayapp/nixpacks:ubuntu-1675123887
ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/
COPY .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix
RUN nix-env -if .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix && nix-collect-garbage -d
ARG CGO_ENABLED NIXPACKS_METADATA
ENV CGO_ENABLED=$CGO_ENABLED NIXPACKS_METADATA=$NIXPACKS_METADATA
# setup phase
# noop
# build phase
COPY . /app/.
RUN --mount=type=cache,id=xmGFbf20G0-/root/cache/go-build,target=/root/.cache/go-build go build -o out main.go
# start
FROM ubuntu:jammy
WORKDIR /app/
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
RUN true
COPY --from=0 /app/ /app/
CMD ["./out", "hello", "world", "cool bro"] NODE: runs inside the NIXPACKS custom docker, and sets the ENTRYPOINT without switching docker stages.FROM ghcr.io/railwayapp/nixpacks:ubuntu-1675123887
ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/
COPY .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix
RUN nix-env -if .nixpacks/nixpkgs-293a28df6d7ff3dec1e61e37cc4ee6e6c0fb0847.nix && nix-collect-garbage -d
ARG CI NIXPACKS_METADATA NODE_ENV NPM_CONFIG_PRODUCTION
ENV CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION
# setup phase
# noop
# install phase
ENV PATH /app/node_modules/.bin:$PATH
RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile
COPY . /app/.
RUN --mount=type=cache,id=OexUejBTDmo-/root/npm,target=/root/.npm npm ci
# build phase
# noop
# start
COPY . /app
CMD ["npm", "run", "start"] |
can you try not splitting and just making it |
@Milo123459 I've done the test you requested. It allowed go to execute properly. But node would simply drop into a shell. Adding the ENTRYPOINT to the golang run_in_slim_image also caused golang to drop into a shell environment. From reading the docker docs, https://docs.docker.com/engine/reference/builder/#cmd , the So now I'm thinking using |
Is there an existing issue for this?
Describe the bug
Nix pack works fine for building a default container. But when I start adding custom start commands, something fails.
Here is a working build & deploy, without start commands
Builds fine but it's just using the default start command.
Here is a build with start commands, it fails
To reproduce
Build a standard golang application with commands. I am using pocketbase.
Add start commands to add to the run command.
Expected behavior
The build to go through like standard, but with start commands.
Environment
Nixpacks 18, on railway
The text was updated successfully, but these errors were encountered: