Clojure language support

Hello there,

I am following the contributor guide and trying to add clojure support to http-server.

However, I am stuck by the following errors

js-tools Docker image built.

Compiling language: clojure...
compiling http-server-clojure
- compiling starter template for http-server-clojure
  - ignoring template interpolation for .gitattributes
  - postprocessing compiled_starters/clojure/README.md
compiled_starters/clojure/README.md 37ms
  - ignoring template interpolation for build.clj
  - ignoring template interpolation for .gitignore
  - ignoring template interpolation for deps.edn
  - ignoring template interpolation for src/main.clj
  - ignoring template interpolation for .codecrafters/run.sh
  - ignoring template interpolation for .codecrafters/compile.sh
- compiling solutions for clojure
- compiling solution diffs for http-server-clojure
Testing languages: clojure

Testing Dockerfile: http-server-clojure-1.12
--------------------------------------------

CodeCrafters was unable to process this Dockerfile. Error: RuntimeError: Unknown from_line: FROM clojure:openjdk-19.

/app/app/lib/buildpack_dockerfile_processor.rb:48:in `build_prelude_lines'
/app/app/lib/buildpack_dockerfile_processor.rb:82:in `process'
/app/app/controllers/services/course_sdk_controller.rb:10:in `process_dockerfile'
/usr/local/bundle/gems/actionpack-8.0.1/lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
/usr/local/bundle/gems/actionpack-8.0.1/lib/abstract_controller/base.rb:226:in `process_action'
/usr/local/bundle/gems/actionpack-8.0.1/lib/action_controller/metal/rendering.rb:193:in `process_action'
/usr/local/bundle/gems/actionpack-8.0.1/lib/abstract_controller/callbacks.rb:261:in `block in process_action'
/usr/local/bundle/gems/activesupport-8.0.1/lib/active_support/callbacks.rb:120:in `block in run_callbacks'
/usr/local/bundle/gems/turbo-rails-2.0.11/lib/turbo-rails.rb:24:in `with_request_id'
/usr/local/bundle/gems/turbo-rails-2.0.11/app/controllers/concerns/turbo/request_id_tracking.rb:10:in `turbo_tracking_request_id'

I am trying to add this Dockerfile

FROM clojure:tools-deps-1.12.0.1501

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="deps.edn"

WORKDIR /app
COPY deps.edn ./

# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

# Install language-specific dependencies
RUN .codecrafters/compile.sh

I believe there are some implicit knowledge I couldn’t find out. Could you please share more insight?

1 Like

Thanks for trying to add clojure support to http-server! :handshake:

I’ll take a look and get back to you early next week.

Thank you! Can’t wait starting the challenge using Clojure.

CodeCrafters was unable to process this Dockerfile. Error: RuntimeError: Unknown from_line: FROM clojure:openjdk-19.

Hi @SughiY, This error occurs because our Dockerfile Processor imposes a limitation on the FROM line.

Our processor currently accepts only Alpine, Dart, and Debian-based images (e.g. bookworm). You may need to use one of these as the base image.

Thank you! I thought of it. I did the test on my m2 macmini, that’s why I couldn’t use -alpine. I was wondering if that was the cause. I will test on wsl2 tonight to see if it can work.

( the link is 404, is it a private repo?)

1 Like

Sorry about the private link. The relevant code looks like this:

1 Like

Thank you for the sharing.

I’ve passed the test with changing to -bookworm and I’ve created a PR for the change.

Please let me know if I need to create an issue.

Best,

@andy1li is there a way to contribute to codecrafters? How can I ?

1 Like

Hey i27ae15, I created a PR following this official document Introduction - CodeCrafters.

2 Likes

@SughiY thank you! Will take a look!

@i27ae15, thanks for your interest in contributing! :golf:

Some parts of the guide above may be outdated, so feel free to post here if anything is unclear.

1 Like

I’ve closed the PR, since clojure actually can run directly in Java docker.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.codecrafters</groupId>
    <artifactId>codecrafters-http-server</artifactId>
    <version>1.0</version>

    <properties>
        <maven.compiler.source>23</maven.compiler.source>
        <maven.compiler.target>23</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>23</java.version>
        <clojure.version>1.12.0</clojure.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.clojure</groupId>
            <artifactId>clojure</artifactId>
            <version>${clojure.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.theoryinpractise</groupId>
                <artifactId>clojure-maven-plugin</artifactId>
                <version>1.8.4</version>
                <extensions>true</extensions>
                <configuration>
                    <sourceDirectories>
                        <sourceDirectory>src</sourceDirectory>
                    </sourceDirectories>
                    <clojureOptions>-Dfile.encoding=UTF-8</clojureOptions>
                </configuration>
                <executions>
                    <execution>
                        <id>compile-clojure</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>codecrafters-http-server</finalName> <!-- Please do not change this final artifact name-->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <appendAssemblyId>false</appendAssemblyId>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <!-- This is the main class of your program which will be executed-->
                            <mainClass>main</mainClass>
                        </manifest>
                    </archive>
                    <outputDirectory>${dir}</outputDirectory>
                </configuration>

                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

So theoretically, all challenges are accessible for clojure. I’ve tested the first tests for http-server and Kafka.

1 Like