[Docker] Add a SQLite Console Shortcut with the Dockerfile
With a long-running node server and a database, sometimes it's useful to ssh into the virtual machine to explore the file system, and look at the database.
In Dockerfile, add:
RUN echo '#!/bin/sh\nset -xe\nsqlite3 \$DATABASE_URL' > /usr/local/bin/database_cli && chmod +x /usr/local/bin/database_cli
This command will create a new file inside user/local/bin/database_cli
. This file will contain a script that runs SQLite 3 on the database URL, and makes sure the script is executable.
After deploying the changes with fly deploy
, you can use fly ssh console -C database_cli
to jump straight into the SQLite CLI.
-
RUN
: This is a Docker command that runs a command in a new layer on top of the current image and commits the result. This is typically used for installing packages, configuring the environment, or other similar tasks. -
echo '#!/bin/sh\nset -xe\nsqlite3 \$DATABASE_URL'
: Theecho
command is used to print the given string to the standard output. In this case, the string is a shell script that consists of three lines:#!/bin/sh
: This is a shebang (or hashbang) line that specifies the interpreter to be used for executing the script, in this case,/bin/sh
(a standard Unix shell).set -xe
: This line sets two options for the shell:-x
: This option tells the shell to print each command before it's executed, which is useful for debugging.-e
: This option tells the shell to exit immediately if any command exits with a non-zero status, which is useful for detecting errors early.
sqlite3 \$DATABASE_URL
: This line runs thesqlite3
command-line tool with the$DATABASE_URL
environment variable as its argument. The backslash before the$
is used to escape it, ensuring that the variable is not expanded when theecho
command is executed but rather when the script is run.
-
> /usr/local/bin/database_cli
: This part of the command redirects the output of theecho
command to a file nameddatabase_cli
in the/usr/local/bin/
directory. This is a standard location for executable files on Unix-like systems. -
&&
: This is a shell control operator that allows you to chain multiple commands together. The second command will only be executed if the first command succeeds (returns a zero exit status). -
chmod +x /usr/local/bin/database_cli
: This command changes the permissions of thedatabase_cli
file to make it executable. The+x
option adds the execute permission for the owner, group, and others.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2022-05-04 [React] Optimization Cookbook
2020-05-04 [Node] Prepare a package to be published to npm
2020-05-04 [React Testing] Test your Custom Hook Module with react-hooks-testing-library
2020-05-04 [React Testing] Test React Portals with within from React Testing Library
2020-05-04 [React Testing] Write React Application Integration Tests with React Testing Library
2020-05-04 [React Testing] Test timer related feature in React
2020-05-04 [React Testing] Test a Custom React Hook with renderHook from React Hooks Testing Library