diff --git a/.devcontainer/devcontainer.env b/.devcontainer/devcontainer.env index 104ee7734..134028f6e 100644 --- a/.devcontainer/devcontainer.env +++ b/.devcontainer/devcontainer.env @@ -67,3 +67,7 @@ MYSQL_ROOT_PASSWORD=db-root-password MYSQL_DATABASE=doubtfire-dev MYSQL_USER=dfire MYSQL_PASSWORD=pwd + +# Latex Details +LATEX_CONTAINER_NAME=formatif-texlive-container +LATEX_BUILD_PATH=/texlive/shell/latex_build.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7dba47230..f04efa507 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,15 +1,18 @@ //devcontainer.json { "name": "Formatif Development Container", - "image": "lmsdoubtfire/formatif-devcontainer:8.3-dev", - "runArgs": ["--env-file", ".devcontainer/devcontainer.env"], + // "image": "lmsdoubtfire/formatif-devcontainer:8.3-dev", + // "runArgs": ["--env-file", ".devcontainer/devcontainer.env"], // "dockerFile": "../dev.Dockerfile", - // "dockerComposeFile": "../development/docker-compose.yml", - // "service": "formatif-dev-container", - // "shutdownAction": "stopCompose", + "dockerComposeFile": "./docker-compose.yml", + "service": "formatif-dev-container", + "shutdownAction": "stopCompose", // "workspaceFolder": "/workspace", + "workspaceFolder": "/workspace", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", + "customizations": { "vscode": { "settings": { @@ -39,41 +42,38 @@ } }, - "mounts": [ - { - "source": "formatif-dev-database", - "target": "/var/lib/mysql", - "type": "volume" - }, - { - "source": "formatif-dev-tmp", - "target": "/workspace/tmp", - "type": "volume" - }, - { - "source": "formatif-dev-student-work", - "target": "/student-work", - "type": "volume" - }, - { - "source": "ws_node_modules", - "target": "/workspace/node_modules", - "type": "volume" - }, - { - "source": "web_node_modules", - "target": "/workspace/doubtfire-web/node_modules", - "type": "volume" - }, - { - "source": "api_bundle", - "target": "/home/vscode/.gems", - "type": "volume" - } - ], - - "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", - "workspaceFolder": "/workspace", + // "mounts": [ + // { + // "source": "formatif-dev-database", + // "target": "/var/lib/mysql", + // "type": "volume" + // }, + // { + // "source": "formatif-dev-tmp", + // "target": "/workspace/tmp", + // "type": "volume" + // }, + // { + // "source": "formatif-dev-student-work", + // "target": "/student-work", + // "type": "volume" + // }, + // { + // "source": "ws_node_modules", + // "target": "/workspace/node_modules", + // "type": "volume" + // }, + // { + // "source": "web_node_modules", + // "target": "/workspace/doubtfire-web/node_modules", + // "type": "volume" + // }, + // { + // "source": "api_bundle", + // "target": "/home/vscode/.gems", + // "type": "volume" + // } + // ], "forwardPorts": [3000, 4200, 9876], diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index e6a972c34..f6ada122c 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,8 +1,7 @@ version: '3' services: formatif-dev-container: - container_name: formatif-dev-container - image: formatif-devcontainer:8.3-dev + container_name: 1-formatif-dev-container build: context: ../ dockerfile: dev.Dockerfile @@ -16,6 +15,7 @@ services: - web_node_modules:/workspace/doubtfire-web/node_modules - formatif_db_compose:/var/lib/mysql - formatif_gems_compose:/home/vscode/.gems + - /var/run/docker.sock:/var/run/docker.sock ports: - "9876:9876" - "4200:4200" @@ -24,6 +24,23 @@ services: command: /bin/sh -c "while sleep 5000; do :; done" env_file: - devcontainer.env + environment: + LATEX_CONTAINER_NAME: 1-formatif-texlive-container + LATEX_BUILD_PATH: /texlive/shell/latex_build.sh + + texlive: + container_name: 1-formatif-texlive-container + build: + context: ../ + dockerfile: texlive.Dockerfile + volumes: + - formatif_student-work_compose:/student-work + - ../doubtfire-api/tmp/rails-latex:/workdir/texlive-latex + - ../doubtfire-api/public/assets/images:/workspace/doubtfire-api/public/assets/images + - ../doubtfire-api/test_files:/workspace/doubtfire-api/test_files + depends_on: + - formatif-dev-container + command: /bin/sh -c "while sleep 5000; do :; done" volumes: ws_node_modules: diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index 791af6ce1..0cbd712a3 100755 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -7,6 +7,7 @@ ln -s /workspace/.devcontainer/.irbrc $HOME sudo chown vscode:vscode /var/lib/mysql +sudo chown vscode:vscode /var/run/docker.sock # sudo chmod a+rw /var/lib/mysql sudo chmod a+rw /workspace/tmp sudo chmod a+rw /workspace/node_modules diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b579cfe16..893767d10 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -21,7 +21,7 @@ { "label": "Serve Rails API", "type": "shell", - "command": "bundle install && rails s", + "command": "bundle install && rails s -b 0.0.0.0", "group": "build", "presentation": { "group": "buildGroup", diff --git a/dev.Dockerfile b/dev.Dockerfile index ca60d1b8d..5af22b8dd 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -79,7 +79,7 @@ RUN apt-get update \ && node --version \ && npm --version \ && gem install bundler -v '~> 2.4.5' \ - && /workspace/doubtfire-api/.ci-setup/texlive-install.sh \ + # && /workspace/doubtfire-api/.ci-setup/texlive-install.sh \ && rm -rf /workspace/doubtfire-api/.ci-setup/texlive-install.sh \ && rm -rf /install-tl-* \ && mkdir /run/mysqld diff --git a/texlive.Dockerfile b/texlive.Dockerfile new file mode 100644 index 000000000..ef52bd3c6 --- /dev/null +++ b/texlive.Dockerfile @@ -0,0 +1,14 @@ +FROM texlive/texlive:latest + +RUN apt-get update \ + && apt-get install -y \ + imagemagick \ + inkscape \ + librsvg2-bin \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY ./doubtfire-api/lib/shell/latex_build.sh /texlive/shell/latex_build.sh +RUN chmod +x /texlive/shell/latex_build.sh + +CMD ["sh", "-c", "while sleep 5000; do :; done"]