Build a PureScript development environment with Docker

Introduction

The other day, I was able to run spago repl on the Docker container, so this time I will check the build and execution of the project created with spago init. Running PureScript on Docker container-Qiita

Verification environment

Windows10 Home Edition
VirtualBox 6.1.16
docker-machine.exe version 0.16.1, build cce350d7

# Docker Host OS (CoreOS)
$ uname -a
Linux default 4.14.154-boot2docker #1 SMP Thu Nov 14 19:19:08 UTC 2019 x86_64 GNU/Linux

Docker version 19.03.5, build 633a0ea838
docker-compose version 1.26.0, build d4451659

Directory structure

Prepare docker-compose.yml, Dockerfile and myapp in the empty folder in the purescript folder.

purescript
├── docker-compose.yml
├── Dockerfile
└── myapp

docker-compose.yml

docker-compose.yml


version: "3.7"
services:
  purescript:
    build:
      context: .
      dockerfile: Dockerfile
      target: "purescript"
    image: takaya030/purescript
    command: "true"
  app:
    build:
      context: .
      dockerfile: Dockerfile
      target: "pure-app"
    image: takaya030/pure-app
    volumes:
      - ./myapp:/home/pureuser/myapp
    working_dir: /home/pureuser/myapp
    command: "spago run"

Dockerfile

Dockerfile


FROM node:12 as purescript
LABEL maintainer "takaya030"

# install purescript
RUN npm install --global --unsafe-perm purescript spago

# add user
RUN userdel node && \
	useradd -m -s /bin/bash pureuser

WORKDIR /home/pureuser
USER pureuser

RUN mkdir tmp && cd tmp && spago init

CMD cd tmp && spago repl

#=========================================
FROM purescript as pure-app

COPY ./myapp /home/pureuser/myapp
WORKDIR /home/pureuser/myapp

CMD ["spago","run"]

Build image

$ cd purescript
$ docker-compose build purescript
$ docker-compose build app

Check the image

$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
takaya030/pure-app     latest              c018082fc97b        27 hours ago        1.08GB
takaya030/purescript   latest              fb50aeb56d04        2 days ago          1.08GB
node                   12                  1f560ce4ce7e        5 weeks ago         918MB

Creating a project

Executing the following command will create an initial project under the myapp folder

$ docker-compose run --rm app spago init

Project file structure

$ ls -l myapp
total 4
-rwxrwxrwx    1 docker   staff         2903 Nov 16 09:53 packages.dhall
-rwxrwxrwx    1 docker   staff          231 Nov 16 09:53 spago.dhall
drwxrwxrwx    1 docker   staff            0 Nov 16 09:57 src
drwxrwxrwx    1 docker   staff            0 Nov 16 09:53 test

Build

In my environment, the pictograms of the sample program are garbled, so I changed it as follows

myapp/src/Main.purs


module Main where

import Prelude

import Effect (Effect)
import Effect.Console (log)

main :: Effect Unit
main = do
  log "Hello, PureScript"

Build with the following command

$ docker-compose run --rm app spago build

[info] Build succeeded.

Run

If the build is successful, execute it with the following command

$ docker-compose run --rm app spago run

Hello, PureScript

reference

-How to get started with PureScript, a pure functional scripting language-- Qiita

Recommended Posts

Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
Build a WordPress development environment quickly with Docker
Build a Node.js environment with Docker
Build a simple Docker + Django development environment
Build a development environment for Docker + Rails6 + Postgresql
Build a Laravel / Docker environment with VSCode devcontainer
Build a simple Docker Compose + Django development environment
Build docker environment with WSL
[Win10] Build a JSF development environment with NetBeans
Build a development environment for Django + MySQL + nginx with Docker Compose
Build a development environment for Docker, java, vscode
[First team development ②] Build an environment with Docker
Create a Spring Boot development environment with docker
Build a Java development environment with VS Code
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Java development environment with WSL2 Docker VS Code
[Environment construction] Build a Java development environment with VS Code!
Try to build a Java development environment using Docker
Create a Vue3 environment with Docker!
Build Couchbase local environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build jooby development environment with Eclipse
Build Unity development environment on docker
Build docker + laravel environment with laradock
Build a development environment to create Ruby on Jets + React apps with Docker
I made a development environment with rails6 + docker + postgreSQL + Materialize.
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a Node-RED environment with Docker to move and understand
I tried to create a padrino development environment with Docker
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
Create a MySQL environment with Docker from 0-> 1
Build a WAS execution environment from Docker
Create Spring Boot-gradle-mysql development environment with Docker
Build a Java development environment on Mac
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a browser test environment using Capybara in the Docker development environment
Steps to build a Ruby on Rails development environment with Vagrant