Skip to content
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

Base clojure template #19

Merged
merged 15 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ jobs:
id: filter
with:
filters: |
color: ./**/color/**
hello: ./**/hello/**
scicloj: ./**/scicloj/**
basecloj: ./**/basecloj/**


test:
Expand Down
31 changes: 31 additions & 0 deletions src/basecloj/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM clojure:temurin-21-tools-deps-jammy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "tag" of the image should be configurable.
Please see here:

and

FROM clojure:${templateOption:imageTag}


ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME


# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
SHELL ["/bin/bash", "-ec"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried as well to make "bash" the defaut shell, but did not succeed neither.When I open a "terminal" in VSCode, I get "sh" first and not "bash".

If you are aware of a way to get a "bash" by default, let me know.

ENTRYPOINT ["bash"]


# Prepare clojure tools
RUN clojure -Ttools list && \
clojure -Ttools install io.github.seancorfield/clj-new '{:git/tag "v1.2.404" :git/sha "d4a6508"}' :as clj-new && \
clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new && \
clojure -Ttools list

RUN sudo apt-get update && \
sudo apt-get install -y lsb-release
28 changes: 28 additions & 0 deletions src/basecloj/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/scicloj/devcontainer-templates/tree/main/src/basecloj
{
"name": "Base clojure dev env",
"build": {
"dockerfile": "Dockerfile",
"args": {
"USERNAME": "${localEnv:USER}"
}
},
"runArgs": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plase remove this, if it is here due to sshd which should be removed

"--security-opt",
"seccomp=unconfined"
],
"remoteUser": "${localEnv:USER}",
"containerUser": "${localEnv:USER}",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/sshd:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"betterthantomorrow.calva"
]
}
}
}
51 changes: 51 additions & 0 deletions src/basecloj/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@



## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|

>Note: comming soon

# A minimal devcontainer with JAVA, Clojure and minimal clj tools

It sets up a minimal dev container environment with green fields minimal tools for Clojure.

# Quickstart

## Without devcontainer cli

0. Clone the repo/src/basecloj folder into a new folder and open it with VSCode.

```bash
git clone --depth 1 https://github.com/scicloj/devcontainer-templates.git devContClojureTemplates
#or download the tag zip file of the repo from https://github.com/scicloj/devcontainer-templates/tags

cp -r devContClojureTemplates/src/basecloj/ myprojectname
code myprojectname
# Choose the option "Reopen in container" when prompted.

# Optionally
rm -rf devContClojureTemplates
```
> Note change "myprojectname" with the correct project name.


## With devcontainer cli

0. Install [devcontainer cli](https://github.com/devcontainers/cli)
1. Run `devcontainer templates apply -t ghcr.io/scicloj/devcontainer-templates/basecloj` to create a devcontainer setup
with default settings in your current directoty
2. Open folder with VSCode / devcontainer / devpod / Codespaces and trigger/wait for container build
3. [Start the Calva repl](https://calva.io/getting-started/)


4. Create a new app, lib, template and more:
* Read [deps-new](https://github.com/seancorfield/deps-new)
* Read [clj-new docs](https://github.com/seancorfield/clj-new)

## Customization
5. Install more features in devcontainer: https://containers.dev/features

---
11 changes: 11 additions & 0 deletions src/basecloj/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "basecloj",
"version": "1.0.0",
"name": "Base clojure development environment",
"description": "A devcontainer template with the minimum clojure tools and configuration, this template is intended to create new greenfield clojure project that should be further customised on specific project needs. ",
"documentationURL": "https://github.com/scicloj/devcontainer-templates/tree/main/src/basecloj",
"licenseURL": "https://github.com/scicloj/devcontainer-templates/blob/main/LICENSE",
"platforms": [
"Any"
]
}
18 changes: 0 additions & 18 deletions src/color/.devcontainer/devcontainer.json

This file was deleted.

17 changes: 0 additions & 17 deletions src/color/README.md

This file was deleted.

32 changes: 0 additions & 32 deletions src/color/devcontainer-template.json

This file was deleted.

4 changes: 0 additions & 4 deletions src/hello/.devcontainer/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions src/hello/.devcontainer/devcontainer.json

This file was deleted.

17 changes: 0 additions & 17 deletions src/hello/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions src/hello/devcontainer-template.json

This file was deleted.

13 changes: 13 additions & 0 deletions test/basecloj/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cd $(dirname "$0")
source test-utils.sh

# Template specific tests
check "distro" lsb_release -a
check "java_jdk" java --version
check "clojure" clojure --version
check "clj" clj --version
check "user" id

# Report result
reportResults
10 changes: 0 additions & 10 deletions test/color/test.sh

This file was deleted.

10 changes: 0 additions & 10 deletions test/hello/test.sh

This file was deleted.

Loading