1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker コンテナ上で PureScript を動かす

Posted at

はじめに

Docker HubPureScript が動作するイメージがいくつかアップされていますが、 Node.js v12 かつ spago を使用しているものが見当たらなかったので自分で作成してみました

検証環境

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

ディレクトリ構成

purescript フォルダの中に docker-compose.ymlDockerfile のみ

purescript
|   docker-compose.yml
|   Dockerfile

docker-compose.yml

docker-compose.yml
version: "3.7"
services:
  purescript:
    build:
      context: .
      dockerfile: Dockerfile
    image: takaya030/purescript

Dockerfile

Dockerfile
FROM node:12
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

イメージのビルド

$ cd purescript
$ docker-compose build purescript

イメージの確認

$ docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
takaya030/purescript   latest              fb50aeb56d04        22 hours ago        1.08GB
node                   12                  1f560ce4ce7e        4 weeks ago         918MB

動作確認

$ docker-compose run --rm purescript

[info] Installing 4 dependencies.
[info] Searching for packages cache metadata..
[info] Unable to find packages cache metadata, downloading from GitHub..
[info] Installing and globally caching "psci-support"
[info] Installing and globally caching "console"
[info] Installing and globally caching "effect"
[info] Installing and globally caching "prelude"
[info] Installation complete.
Compiling Type.Data.RowList
Compiling Type.Data.Row
Compiling Record.Unsafe
  .
  .
  .
Compiling Main
Compiling PSCI.Support
Compiling Test.Main
PSCi, version 0.13.8
Type :? for help

import Prelude

> "hello"
"hello"

> 1 + 2 * 3
7

> import Effect.Console
> log "print this to the screen"
print this to the screen
unit

> :quit
See ya!
()

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?