Add docker environment for local development (#257)
* Add docker environment * Add document of docker * Move docker files * Change context * Move git submodule command to entrypoint.sh * Update README
This commit is contained in:
parent
abb770ebd1
commit
030c52020e
4 changed files with 61 additions and 0 deletions
16
README.md
16
README.md
|
|
@ -87,6 +87,22 @@ separately to build the frontend. When making changes to the frontend it
|
|||
should be enough to simply run `nimble frontend` again to rebuild. This command
|
||||
will also build the SASS ``nimforum.scss`` file in the `public/css` directory.
|
||||
|
||||
### With docker
|
||||
|
||||
You can easily launch site on localhost if you have `docker` and `docker-compose`.
|
||||
You don't have to setup dependencies (libsass, sglite, pcre, etc...) on you host PC.
|
||||
|
||||
To get up and running:
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
And you can access local NimForum site.
|
||||
Open http://localhost:5000 .
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
You might have to run `nimble install karax@#5f21dcd`, if setup fails
|
||||
|
|
|
|||
14
docker/Dockerfile
Normal file
14
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
FROM nimlang/nim:1.2.6-ubuntu
|
||||
|
||||
RUN apt-get update -yqq \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
libsass-dev \
|
||||
sqlite3 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
# install dependencies
|
||||
RUN nimble install -Y
|
||||
12
docker/docker-compose.yml
Normal file
12
docker/docker-compose.yml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
version: "3.7"
|
||||
|
||||
services:
|
||||
forum:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: ./docker/Dockerfile
|
||||
volumes:
|
||||
- "../:/app"
|
||||
ports:
|
||||
- "5000:5000"
|
||||
entrypoint: "/app/docker/entrypoint.sh"
|
||||
19
docker/entrypoint.sh
Executable file
19
docker/entrypoint.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
git submodule update --init --recursive
|
||||
|
||||
# setup
|
||||
nimble c -d:release src/setup_nimforum.nim
|
||||
./src/setup_nimforum --dev
|
||||
|
||||
# build frontend
|
||||
nimble c -r src/buildcss
|
||||
nimble js -d:release src/frontend/forum.nim
|
||||
mkdir -p public/js
|
||||
cp src/frontend/forum.js public/js/forum.js
|
||||
|
||||
# build backend
|
||||
nimble c src/forum.nim
|
||||
./src/forum
|
||||
Loading…
Add table
Add a link
Reference in a new issue