diff --git a/images/java/Dockerfile b/images/java/Dockerfile index ce8c136..1962c5b 100644 --- a/images/java/Dockerfile +++ b/images/java/Dockerfile @@ -19,7 +19,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -FROM ghcr.io/auguwu/coder-images/base +# use April 26th image (since Adoptium doesn't support Ubuntu Lunar yet) +FROM ghcr.io/auguwu/coder-images/base:2023.04.26 ENV USERNAME=noel diff --git a/template/main.tf b/template/main.tf index 2c498e7..6005268 100644 --- a/template/main.tf +++ b/template/main.tf @@ -96,22 +96,24 @@ resource "coder_agent" "main" { # Run Docker in the background if command -v dockerd &> /dev/null; then - sudo dockerd & + sudo dockerd > /dev/null 2>&1 & fi + # Wait for Docker to start + while true; do + if curl -s --unix-socket /var/run/docker.sock http/_ping 2>&1 >/dev/null; then + echo "Docker Daemon has started!" + break + fi + + echo "Waiting for Docker daemon to start..." + sleep 1 + done + # Install code-server if enabled ${var.install_codeserver == true ? "curl -fsSL https://code-server.dev/install.sh | sh" : ""} ${var.install_codeserver == true ? "code-server --auth none --port 3621" : ""} - # I don't know why this happens but, the base Rust image loses all information, so we - # will re-run the rustup-init script, which is still present. - if [ -x /tmp/rustup-init ]; then - /tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain nightly --default-host=x86_64-unknown-linux-gnu - source $HOME/.cargo/env - - rustup component add clippy rustfmt - fi - # Clone the given repository if needed if ! [ -d "${var.workspace_dir}" ]; then ${var.git_repository != "" ? "git clone ${var.git_repository} ${var.workspace_dir}" : ""} @@ -121,6 +123,10 @@ resource "coder_agent" "main" { mkdir ${var.workspace_dir} fi + if [ -n "${var.docker_network_name}" ]; then + docker network create "${var.docker_network_name}" --driver=bridge + fi + # if ${var.workspace_dir}/.coder exists, then we will run the pre-init scripts # and then the Docker Compose project (if any). if [ -d "${var.workspace_dir}/.coder" ]; then @@ -144,7 +150,8 @@ resource "coder_agent" "main" { dc="docker compose" fi - if [ -z "$dc" ]; then + if [ -n "$dc" ]; then + echo "[coder::docker-compose] Using \`$dc\` as the Docker compose command!" $dc -f "${var.workspace_dir}/.coder/docker-compose.yml" up -d fi fi diff --git a/template/variables.tf b/template/variables.tf index 8a6ae98..e8e38a6 100644 --- a/template/variables.tf +++ b/template/variables.tf @@ -65,3 +65,9 @@ variable "dotfiles_repo" { default = "" type = string } + +variable "docker_network_name" { + description = "Name of the Docker network to use." + default = "fluff" + type = string +}