Git Product home page Git Product logo

mint-docker's Introduction

Mint in Docker

This repository offers a starting point of running mint in Docker. It uses Docker Compose so you should have it installed.

The default scaffolded application is located in the workspace folder and it's used as a starting point.

If you only want to use Docker check the end of this readme.

Avaiable Commands

This repository makes use of a Makefile to achieve short commands.

Development Server

Run make or make server to start a development server:

$ make
docker-compose run --rm --service-ports mint start --host 0.0.0.0
Mint - Running the development server
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 130μs
⚙ Parsing files... 20.682ms
⚙ Development server started on http://0.0.0.0:3000/

Build

Run make build to build the final files into the workspace/dist folder:

$ make build
docker-compose run --rm mint build
Mint - Building for production
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 0μs
⚙ Clearing the "dist" directory... 376μs
⚙ Compiling your application:
  ➔ Parsing 4 source files... 17.345ms
  ➔ Type checking: 22.129ms
  ➔ Compiling: 2.541ms
⚙ Writing external stylesheets...165μs
⚙ Writing index.html... 587μs
⚙ Writing manifest.webmanifest...140μs
⚙ Generating icons... 363.919ms
⚙ Creating service worker...1.079ms
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 2.274s!

Formatting Files

Run make format to format all source files:

$ make format
docker-compose run --rm mint format
Mint - Formatting files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All files are formatted!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 41.795ms!

Install Dependencies

Run make install to install any dependencies you added:

$ make install
docker-compose run --rm mint install
Mint - Installing dependencies
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
There are no dependencies!

There is nothing to do!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 119μs!

Plain Docker

You can use plain Docker to achieve the same commands above.

You will need to pull the latest image:

$ docker pull ghcr.io/mint-lang/mint

If you are on windows you need to change $(pwd)/workspace to the absolute path of the workspace folder.

Development Server

To run the development server run the following command:

docker run --tty -v $(pwd)/workspace:/workspace -w /workspace -p 3000:3000 --rm -ti mint start -h 0.0.0.0

Build

To create a build run:

docker run --tty -v $(pwd)/workspace:/workspace -w /workspace --rm -ti mint build

Formatting Files

To format files run:

docker run --tty -v $(pwd)/workspace:/workspace -w /workspace --rm -ti mint format

Install Dependencies

To install dependencies run:

docker run --tty -v $(pwd)/workspace:/workspace -w /workspace --rm -ti mint install

mint-docker's People

Contributors

gdotdesign avatar sija avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mint-docker's Issues

Alternative usage with all mint commands

Prepare

Create such Dockerfile:

FROM alpine:latest

# you may want to change URL to https://mint-lang.s3-eu-west-1.amazonaws.com/mint-latest-linux if want pre-release version
RUN wget -O mint https://github.com/mint-lang/mint/releases/download/0.7.1/mint-0.7.1-linux
RUN chmod +x mint

EXPOSE 3000
WORKDIR /proj
ENTRYPOINT ["/mint"]

Then invoke this command from the path where Dockerfile is installed, to build the docker image:

docker build -t mint .

Basic usage

To invoke just the basic mint command do it like this:

docker run --tty -v c:/dev/Projects/my_project:/proj -p 3000:3000 --rm -ti mint

It maps the c:/dev/Projects/my_project directory to container-local working directory (called proj) for mint.

Append to this command anything that's going to be a parameter for mint command.

Working on a project

Init project called my_project in directory c:/dev/Projects which will create a folder my_project:

docker run --tty -v c:/dev/Projects:/proj mint init my_project

To run mint start from the project directory c:/dev/Projects/my_project invoke:

docker run --tty -v c:/dev/Projects/my_project:/proj -p 3000:3000 --rm -ti mint start -h 0.0.0.0

then open http://localhost:3000

Running on Windows

On Windows you may want to use this batch file mint_start.bat by invoking directly from project's directory:

@echo off
echo Run this batch from project's directory!
docker run --tty -v "%cd%":/proj -p 3000:3000 --rm -ti mint start -h 0.0.0.0

then open http://localhost:3000

and mint_test.bat:

@echo off
echo Run this batch from project's directory!
docker run --tty -v "%cd%":/proj -p 3001:3001 --rm -ti mint test --manual --host 0.0.0.0

then open http://localhost:3001

Fails to Build on M1 Mac

I am attempting to run the Docker container and it is failing to build on my M1 Macbook Pro. The output is below:

~/dev/mint-docker(master) » docker-compose up -d                                                                                               joshp@Joshs-MacBook-Pro
Building mint
[+] Building 19.6s (12/16)
 => [internal] load build definition from Dockerfile.alpine                                                                                                       0.4s
 => => transferring dockerfile: 44B                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                 0.5s
 => => transferring context: 34B                                                                                                                                  0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                  1.1s
 => [internal] load metadata for docker.io/crystallang/crystal:1.0.0-alpine                                                                                       1.0s
 => [build 1/6] FROM docker.io/crystallang/crystal:1.0.0-alpine@sha256:c9b59f80f6b3821596f45494cd56c3b08048067e18ff0b12c26888830fe167d6                           0.0s
 => [stage-1 1/5] FROM docker.io/library/alpine@sha256:ec14c7992a97fc11425907e908340c6c3d6ff602f5f13d899e6b7027c9b4133a                                           0.0s
 => CACHED [stage-1 2/5] RUN mkdir -p /opt/mint                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                 0.3s
 => => transferring context: 58B                                                                                                                                  0.0s
 => CACHED [build 2/6] RUN mkdir -p /opt/build                                                                                                                    0.0s
 => CACHED [build 3/6] WORKDIR /opt/build                                                                                                                         0.0s
 => CACHED [build 4/6] RUN git clone https://github.com/mint-lang/mint.git .                                                                                      0.0s
 => ERROR [build 5/6] RUN shards install --ignore-crystal-version                                                                                                17.8s
------
 > [build 5/6] RUN shards install --ignore-crystal-version:
#11 0.858 Resolving dependencies
#11 0.858 Fetching https://github.com/mosop/string_inflection.git
#11 1.842 Fetching https://github.com/schovi/baked_file_system.git
#11 2.679 Fetching https://github.com/kemalcr/kemal.git
#11 3.886 Fetching https://github.com/luislavena/radix.git
#11 4.710 Fetching https://github.com/jeromegn/kilt.git
#11 5.464 Fetching https://github.com/crystal-loot/exception_page.git
#11 7.361 Fetching https://github.com/jwaldrip/admiral.cr.git
#11 8.240 Fetching https://github.com/gdotdesign/tree_template.git
#11 9.206 Fetching https://github.com/vladfaust/time_format.cr.git
#11 9.971 Fetching https://github.com/gdotdesign/cr-dotenv.git
#11 10.71 Fetching https://github.com/icyleaf/markd.git
#11 11.63 Fetching https://github.com/crystal-ameba/ameba.git
#11 13.62 Fetching https://github.com/makenowjust/crystal-diff.git
#11 16.40 Installing string_inflection (0.2.1)
#11 16.45 Installing baked_file_system (0.9.8 at 7183bfd)
#11 16.49 Installing radix (0.3.9)
#11 16.53 Installing kilt (0.4.0)
#11 16.56 Installing exception_page (0.1.4)
#11 16.60 Installing kemal (0.27.0)
#11 16.64 Installing admiral (1.11.2)
#11 16.69 Installing tree_template (0.1.0 at 7e24c92)
#11 16.74 Installing time_format (0.1.1)
#11 16.77 Installing dotenv (0.3.1)
#11 16.81 Installing markd (0.4.0)
#11 16.85 Installing ameba (0.14.0)
#11 16.90 Postinstall of ameba: make bin && make run_file
#11 17.51 Failed postinstall of ameba on make bin && make run_file:
#11 17.51 /usr/bin/shards build
#11 17.51 Dependencies are satisfied
#11 17.51 Building: ameba
#11 17.51 Error target ameba failed to compile:
#11 17.51 GC Warning: Failed to expand heap by 1175552 bytes
#11 17.51 GC Warning: Failed to expand heap by 1277952 bytes
#11 17.51 GC Warning: Failed to expand heap by 1347584 bytes
#11 17.51 GC Warning: Failed to expand heap by 262144 bytes
#11 17.51 GC Warning: Out of Memory! Heap size: 3 MiB. Returning NULL!
#11 17.51 Invalid memory access (signal 11) at address 0xd8
#11 17.51 [0x4000c5ebf6] ???
#11 17.51 [0x4000badab2] ???
#11 17.51 [0x4001bf5e0f] ???
#11 17.51
#11 17.51 make: *** [Makefile:8: bin/ameba] Error 1
------
executor failed running [/bin/sh -c shards install --ignore-crystal-version]: exit code: 1
ERROR: Service 'mint' failed to build

docker-compose up not working as advertised

Following the installation instructions for Usage with Docker, docker-compose up failed with the following trace:

Click to expand:

Unable to satisfy the following requirements: `crystal (~> 0.23, >= 0.23.1)` required by `string_inflection 0.2.1` ...

Creating network "mint-docker_default" with the default driver
Building mint
failed to get console mode for stdout: The handle is invalid.
[+] Building 40.7s (14/18)
 => [internal] load build definition from Dockerfile.alpine                0.0s
 => => transferring dockerfile: 481B                                       0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 68B                                           0.0s
 => [internal] load metadata for docker.io/library/alpine:latest          12.1s
 => [internal] load metadata for docker.io/crystallang/crystal:0.36.1-al  12.1s
 => [auth] crystallang/crystal:pull token for registry-1.docker.io         0.0s
 => [auth] library/alpine:pull token for registry-1.docker.io              0.0s
 => [stage-1 1/5] FROM docker.io/library/alpine@sha256:ec14c7992a97fc1142  6.5s
 => => resolve docker.io/library/alpine@sha256:ec14c7992a97fc11425907e908  0.0s
executor failed running [/bin/sh -c shards install]: exit code: 1
 => => sha256:49f356fa4513676c5e22e3a8404aad6c7262cc7aaed 1.47kB / 1.47kB  0.0s
 => => sha256:ec14c7992a97fc11425907e908340c6c3d6ff602f5f 1.64kB / 1.64kB  0.0s
 => => sha256:e103c1b4bf019dc290bcc7aca538dc2bf7a9d0fc836e186 528B / 528B  0.0s
 => => sha256:ca3cd42a7c9525f6ce3d64c1a70982613a8235f0cc0 2.81MB / 2.81MB  6.2s
 => => extracting sha256:ca3cd42a7c9525f6ce3d64c1a70982613a8235f0cc057ec9  0.2s
 => [internal] load build context                                          0.0s
 => => transferring context: 150B                                          0.0s
 => [build 1/6] FROM docker.io/crystallang/crystal:0.36.1-alpine@sha256:  12.6s
 => => resolve docker.io/crystallang/crystal:0.36.1-alpine@sha256:ee97e1e  0.0s
 => => sha256:32061617db13060cab6395263d4c0dc995f81dc49 28.21MB / 28.21MB  5.1s
 => => sha256:ee97e1ef8b609cd80a8d504fdf8c5c09f7ac2fc520d 1.37kB / 1.37kB  0.0s
 => => sha256:32474966bd9f6b4df48b92f1bd494b116936aa5d743 3.03kB / 3.03kB  0.0s
 => => sha256:f84cab65f19f5d625a4b5f895cdf37ad9f21e160bf2 2.80MB / 2.80MB  0.4s
 => => sha256:7cef3a20973ccc1086b868afd608b1c8d9e0abd8e 73.88MB / 73.88MB  7.6s
 => => extracting sha256:f84cab65f19f5d625a4b5f895cdf37ad9f21e160bf201ec5  0.2s
 => => sha256:7ee496be9f444cb3aca9b09f9e90e3e804f8bc2e3 28.74MB / 28.74MB  5.4s
 => => sha256:99311fcb4867db2098885ff7028bd8dcaf88010dfc4 1.04kB / 1.04kB  5.3s
 => => extracting sha256:7cef3a20973ccc1086b868afd608b1c8d9e0abd8e2873555  3.1s
 => => extracting sha256:32061617db13060cab6395263d4c0dc995f81dc49b470676  0.2s
 => => extracting sha256:7ee496be9f444cb3aca9b09f9e90e3e804f8bc2e3554dec6  1.2s
 => => extracting sha256:99311fcb4867db2098885ff7028bd8dcaf88010dfc4ee68c  0.0s
 => [stage-1 2/5] RUN mkdir -p /opt/mint                                   0.4s
 => [build 2/6] RUN mkdir -p /opt/build                                    0.5s
 => [build 3/6] WORKDIR /opt/build                                         0.0s
 => [build 4/6] RUN git clone https://github.com/mint-lang/mint.git .      2.0s
 => ERROR [build 5/6] RUN shards install                                  13.4s
------
 > [build 5/6] RUN shards install:
#13 0.364 Resolving dependencies
#13 0.364 Fetching https://github.com/mosop/string_inflection.git
#13 1.591 Fetching https://github.com/schovi/baked_file_system.git
#13 2.415 Fetching https://github.com/kemalcr/kemal.git
#13 3.745 Fetching https://github.com/luislavena/radix.git
#13 4.554 Fetching https://github.com/jeromegn/kilt.git
#13 5.239 Fetching https://github.com/crystal-loot/exception_page.git
#13 5.975 Fetching https://github.com/jwaldrip/admiral.cr.git
#13 6.986 Fetching https://github.com/gdotdesign/tree_template.git
#13 8.175 Fetching https://github.com/vladfaust/time_format.cr.git
#13 8.887 Fetching https://github.com/gdotdesign/cr-dotenv.git
#13 9.702 Fetching https://github.com/icyleaf/markd.git
#13 10.81 Fetching https://github.com/crystal-ameba/ameba.git
#13 12.36 Ignoring source of "diff" on shard.lock
#13 12.36 Fetching https://github.com/MakeNowJust/crystal-diff.git
#13 13.35 Unable to satisfy the following requirements:
#13 13.35
#13 13.35 - `crystal (~> 0.23, >= 0.23.1)` required by `string_inflection 0.2.1`
#13 13.35 - `crystal (~> 0.25, >= 0.25.0)` required by `baked_file_system 0.9.8+git.commit.7183bfde8d86a976a6912f582b51cbd1783456af`
#13 13.35 - `crystal (~> 0.35, >= 0.35.0)` required by `kemal 0.27.0`
#13 13.35 - `crystal (~> 0.34, >= 0.34.0)` required by `admiral 1.11.2`
#13 13.35 - `crystal (< 1.0.0)` required by `tree_template 0.1.0+git.commit.7e24c92208cc99938f3fbd8f5fecda22bcbe3cc3`
#13 13.35 - `crystal (~> 0.24, >= 0.24.2)` required by `time_format 0.1.1`
#13 13.35 - `crystal (< 1.0.0)` required by `dotenv 0.3.1`
#13 13.35 - `crystal (~> 1.0, >= 1.0.0)` required by `markd 0.4.0`
#13 13.35 - `crystal (>= 0.35.0)` required by `ameba 0.14.0`
#13 13.35 - `crystal (< 1.0.0)` required by `diff 1.1.0`
#13 13.35 - `crystal (< 1.0.0)` required by `radix 0.3.9`
#13 13.35 Failed to resolve dependencies, try updating incompatible shards or use --ignore-crystal-version as a workaround if no update is available.
------
ERROR: Service 'mint' failed to build

Steps to reproduce:

  1. clone repository: git clone https://github.com/mint-lang/mint-docker.git
  2. Run docker-compose up in the cloned folder.

System information:

Windows: 10 Home (10.0.19043 Build 19043, x64-based PC)
Docker: version 20.10.5, build 55c4c88
docker-compose: version 1.28.5, build c4eb3a1f

make dumps out on Mac m1

Or maybe I'm a noob.

Possibly related to underlying crystal issues? https://forum.crystal-lang.org/t/memory-leak-after-upgrading-to-crystal-0-36/3035

  ~/Sites > git clone https://github.com/mint-lang/mint-docker.git
Cloning into 'mint-docker'...
remote: Enumerating objects: 82, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 82 (delta 8), reused 41 (delta 8), pack-reused 40
Unpacking objects: 100% (82/82), done.
  ~/Sites > cd mint-docker/
  ~/Sites/mint-docker > make
docker-compose run --rm --service-ports mint start --host 0.0.0.0
Creating mint-docker_mint_run ... done
Mint - Running the development server
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙ Ensuring dependencies... 13.429ms
⚙ Parsing files... 117.184ms
GC Warning: Failed to expand heap by 1216512 bytes
GC Warning: Failed to expand heap by 1224704 bytes
GC Warning: Failed to expand heap by 1245184 bytes
GC Warning: Failed to expand heap by 1282048 bytes
GC Warning: Failed to expand heap by 1306624 bytes
GC Warning: Failed to expand heap by 1343488 bytes
GC Warning: Failed to expand heap by 1368064 bytes
GC Warning: Failed to expand heap by 69632 bytes
GC Warning: Out of Memory! Heap size: 3 MiB. Returning NULL!
Invalid memory access (signal 11) at address 0x77c0
[0x4000108e26] ???
[0x400007e7dc] ???
[0x4000cecfea] ???
[0x4000d045dc] ???
ERROR: 11
make: *** [server] Error 11

Mint base image on DockerHub

Hey again! This is a follow-up to #3. It would be nice to have an image people can pull from DockerHub to use Mint in their workflows. We could create an organization there called mint-lang and push the image from #3 as mint-lang/mint or similar.

We could then offer an alternate way to install in Docker on https://www.mint-lang.com/install ­like so:

$ docker pull mint-lang/mint
$ docker run --rm -it -v $PWD:/opt/mint ming-lang/mint init hello-mint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.