Skip to content

Error during formatDockerfileContents #25

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

Open
NancyKunath opened this issue Apr 17, 2025 · 8 comments
Open

Error during formatDockerfileContents #25

NancyKunath opened this issue Apr 17, 2025 · 8 comments

Comments

@NancyKunath
Copy link

Formatting a dockerfile like this

console.log(
  await formatDockerfileContents(`
FROM nginx
WORKDIR /app
ARG PROJECT_DIR=/
ARG NGINX_CONF=nginx.conf
COPY $NGINX_CONF /etc/nginx/conf.d/nginx.conf
COPY $PROJECT_DIR /app
CMD mkdir --parents /var/log/nginx && nginx -g "daemon off;"
`.trim(),
    {
      indent: 4,
      spaceRedirects: false,
      trailingNewline: true,
    },
  ),
);

Leads to the following error:
Image

In the end, this results in prettier-plugin-sh failing because of our Dockerfile.

@reteps
Copy link
Owner

reteps commented Apr 18, 2025

If you add a newline (don't trim), does it work?

@reteps
Copy link
Owner

reteps commented Apr 18, 2025

Actually, this looks like an issue in the TinyGo. tinygo-org/tinygo#4376

@reteps
Copy link
Owner

reteps commented Apr 18, 2025

@JounQin If you want to take a crack at fixing this, that would be great!

@JounQin
Copy link
Contributor

JounQin commented Apr 19, 2025

If you want to take a crack at fixing this, that would be great!

How could I if it's a tinygo's issue?

@reteps
Copy link
Owner

reteps commented Apr 26, 2025

tinygo-org/tinygo#4277

@JounQin
Copy link
Contributor

JounQin commented Apr 27, 2025

Maybe easyjson should be used. 🤦‍♂️

@reteps
Copy link
Owner

reteps commented Apr 28, 2025

😄 Let's give it a few weeks on tinygo's end and see if there is any progress. If not, I'll see if I can switch to easyjson.

@JounQin
Copy link
Contributor

JounQin commented Apr 28, 2025

I may add a try catch for dockerfmt parser and fallback to sh automatically in the prettier plugin, if anyone is interested to raise a PR for it, that would be appreciated. I'm a bit busy these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants