0
0

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 1 year has passed since last update.

【Dokcer】bashの操作ログを永続化する【Remote-Containers】

Posted at

bashの操作ログを永続化する

Docker

Dockerfile
FROM node:16.15.0

ENV TZ=Asia/Tokyo
ARG USERNAME=node

RUN corepack enable npm
RUN SNIPPET='\n if [ "$SHLVL" = "2" ] ; then \n \
            \t script -f /bashlog/script/`date "+%Y%m%d%H%M%S"`.log \n \
            fi \n \
            \n export PROMPT_COMMAND="history -a" && export HISTFILE=/bashlog/.bash_history \n' \
    && mkdir -p /bashlog/script\
    && touch /bashlog/.bash_history \
    && chown -R ${USERNAME} /bashlog \
    && echo ${SNIPPET} >> "/home/${USERNAME}/.bashrc"

USER ${USERNAME}
RUN mkdir -p /home/${USERNAME}/.vscode-server/extensions
WORKDIR /myapp-frontend

EXPOSE 3000

/docker-compose.yml
version: '3.9'
services:
  frontend:
    build: .
    volumes:
      - sources:/myapp-frontend
      - bashlog:/bashlog
      - vscode-extensions:/home/node/.vscode-server/extensions
    environment:
      NODE_ENV: development
    ports:
      - 3000:3000
      - 9229:9229
    command: /bin/sh -c "while sleep 1000; do :; done"
volumes:
  sources:
  bashlog:
  vscode-extensions:

Remote-Containers

.devcontainer/devcontainer.json
{
  "name": "myapp-frontend",
  "dockerComposeFile": ["../docker-compose.yml"],
  "service": "frontend",
  "workspaceFolder": "/myapp-frontend",
  "customizations": {
    "vscode": {
      "extensions": [
        "EditorConfig.EditorConfig",
        "dbaeumer.vscode-eslint",
        "esbenp.prettier-vscode",
        "VisualStudioExptTeam.vscodeintellicode",
        "arcanis.vscode-zipfs",
        "bradlc.vscode-tailwindcss"
      ]
    }
  }
}
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?