tdiary-io-mongodb 4.1.2 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e6b349a85fc452c7ea2cf4bc01cf7de45c62c26c
4
- data.tar.gz: 1598483047806910ce62a43f9283e95db20ae8a5
2
+ SHA256:
3
+ metadata.gz: 8e5fd6061a24098db620d9429d7196d5bda51b7570b24b801bb8df95065f2241
4
+ data.tar.gz: '098ffdd8da60f6bd146defa7813445605a03ed3b6ab61e13d37d380678b5ec33'
5
5
  SHA512:
6
- metadata.gz: 632c0f72a36aa6726be64898af5802fbd89897643017c47538234e25b22807f8d382fb0063c1f8ab2c2215110ad9617602d2f08d3272db184e0c4581fe7300ce
7
- data.tar.gz: 80e991a6e426165ec1b73c3401696b88bea9942d54ce5a91d153fce81fe6dc764352e727aab2b7933f4b7c0a4c17c1a61dd95b080e8aec61b93ad5d4d8da678b
6
+ metadata.gz: 3d38d2e0032323f9d02b1afa5553dde1195c200e52d4a4780339e8e5e3644ba4666bea9638c617f1546f57e9e93cc9f1b4b9d11b08af524d0483ee520a46b262
7
+ data.tar.gz: 24f85a2a63b9eeba10d98bb46127a3b61495a516a66cdf76238b7e454c45ac2e238e6f124ee4c845a728fb4685c87db2a129579f6620c249fe89aa7a88b9b828
@@ -0,0 +1,20 @@
1
+ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/ruby/.devcontainer/base.Dockerfile
2
+
3
+ # [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6, 2.5
4
+ ARG VARIANT="3"
5
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
6
+
7
+ # [Option] Install Node.js
8
+ ARG INSTALL_NODE="true"
9
+ ARG NODE_VERSION="lts/*"
10
+ RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11
+
12
+ # [Optional] Uncomment this section to install additional OS packages.
13
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
14
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
15
+
16
+ # [Optional] Uncomment this line to install additional gems.
17
+ # RUN gem install <your-gem-names-here>
18
+
19
+ # [Optional] Uncomment this line to install global node packages.
20
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,32 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/docker-from-docker-compose
3
+ {
4
+ "name": "MongoDB IO for tDiary",
5
+ "dockerComposeFile": "docker-compose.yml",
6
+ "service": "app",
7
+ "workspaceFolder": "/workspace",
8
+
9
+ // Use this environment variable if you need to bind mount your local source code into a new container.
10
+ "remoteEnv": {
11
+ "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
12
+ },
13
+
14
+ // Set *default* container specific settings.json values on container create.
15
+ "settings": {
16
+ },
17
+
18
+ // Add the IDs of extensions you want installed when the container is created.
19
+ "extensions": [
20
+ "ms-azuretools.vscode-docker",
21
+ "github.vscode-pull-request-github"
22
+ ],
23
+
24
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
25
+ // "forwardPorts": [],
26
+
27
+ // Use 'postCreateCommand' to run commands after the container is created.
28
+ // "postCreateCommand": "docker --version",
29
+
30
+ // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
31
+ "remoteUser": "vscode"
32
+ }
@@ -0,0 +1,39 @@
1
+ version: '3'
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ args:
9
+ # On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
10
+ USER_UID: 1000
11
+ USER_GID: 1000
12
+ INSTALL_NODE: "false"
13
+ environment:
14
+ - MONGODB_URI=mongodb://mongodb:27017/tdiary_test
15
+ volumes:
16
+ # Forwards the local Docker socket to the container.
17
+ - /var/run/docker.sock:/var/run/docker-host.sock
18
+ # Update this to wherever you want VS Code to mount the folder of your project
19
+ - ..:/workspaces/mongodb:cached
20
+
21
+ # Overrides default command so things don't shut down after the process ends.
22
+ # entrypoint: /usr/local/share/docker-init.sh
23
+ command: sleep infinity
24
+
25
+ # Uncomment the next four lines if you will use a ptrace-based debuggers like C++, Go, and Rust.
26
+ # cap_add:
27
+ # - SYS_PTRACE
28
+ # security_opt:
29
+ # - seccomp:unconfined
30
+
31
+ # Uncomment the next line to use a non-root user for all processes.
32
+ # user: vscode
33
+
34
+ # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
35
+ # (Adding the "ports" property to this file will not forward from a Codespace.)
36
+ mongodb:
37
+ image: mongo:4.4
38
+ ports:
39
+ - 27017:27017
@@ -0,0 +1,340 @@
1
+ #!/usr/bin/env bash
2
+ #-------------------------------------------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5
+ #-------------------------------------------------------------------------------------------------------------
6
+ #
7
+ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/common.md
8
+ #
9
+ # Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My *! flag]
10
+
11
+ INSTALL_ZSH=${1:-"true"}
12
+ USERNAME=${2:-"automatic"}
13
+ USER_UID=${3:-"automatic"}
14
+ USER_GID=${4:-"automatic"}
15
+ UPGRADE_PACKAGES=${5:-"true"}
16
+ INSTALL_OH_MYS=${6:-"true"}
17
+
18
+ set -e
19
+
20
+ if [ "$(id -u)" -ne 0 ]; then
21
+ echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
22
+ exit 1
23
+ fi
24
+
25
+ # Ensure that login shells get the correct path if the user updated the PATH using ENV.
26
+ rm -f /etc/profile.d/00-restore-env.sh
27
+ echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
28
+ chmod +x /etc/profile.d/00-restore-env.sh
29
+
30
+ # If in automatic mode, determine if a user already exists, if not use vscode
31
+ if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
32
+ USERNAME=""
33
+ POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
34
+ for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
35
+ if id -u ${CURRENT_USER} > /dev/null 2>&1; then
36
+ USERNAME=${CURRENT_USER}
37
+ break
38
+ fi
39
+ done
40
+ if [ "${USERNAME}" = "" ]; then
41
+ USERNAME=vscode
42
+ fi
43
+ elif [ "${USERNAME}" = "none" ]; then
44
+ USERNAME=root
45
+ USER_UID=0
46
+ USER_GID=0
47
+ fi
48
+
49
+ # Load markers to see which steps have already run
50
+ MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
51
+ if [ -f "${MARKER_FILE}" ]; then
52
+ echo "Marker file found:"
53
+ cat "${MARKER_FILE}"
54
+ source "${MARKER_FILE}"
55
+ fi
56
+
57
+ # Ensure apt is in non-interactive to avoid prompts
58
+ export DEBIAN_FRONTEND=noninteractive
59
+
60
+ # Function to call apt-get if needed
61
+ apt-get-update-if-needed()
62
+ {
63
+ if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
64
+ echo "Running apt-get update..."
65
+ apt-get update
66
+ else
67
+ echo "Skipping apt-get update."
68
+ fi
69
+ }
70
+
71
+ # Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
72
+ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
73
+ apt-get-update-if-needed
74
+
75
+ PACKAGE_LIST="apt-utils \
76
+ git \
77
+ openssh-client \
78
+ gnupg2 \
79
+ iproute2 \
80
+ procps \
81
+ lsof \
82
+ htop \
83
+ net-tools \
84
+ psmisc \
85
+ curl \
86
+ wget \
87
+ rsync \
88
+ ca-certificates \
89
+ unzip \
90
+ zip \
91
+ nano \
92
+ vim-tiny \
93
+ less \
94
+ jq \
95
+ lsb-release \
96
+ apt-transport-https \
97
+ dialog \
98
+ libc6 \
99
+ libgcc1 \
100
+ libkrb5-3 \
101
+ libgssapi-krb5-2 \
102
+ libicu[0-9][0-9] \
103
+ liblttng-ust0 \
104
+ libstdc++6 \
105
+ zlib1g \
106
+ locales \
107
+ sudo \
108
+ ncdu \
109
+ man-db \
110
+ strace"
111
+
112
+ # Install libssl1.1 if available
113
+ if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
114
+ PACKAGE_LIST="${PACKAGE_LIST} libssl1.1"
115
+ fi
116
+
117
+ # Install appropriate version of libssl1.0.x if available
118
+ LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
119
+ if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
120
+ if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
121
+ # Debian 9
122
+ PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.2"
123
+ elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
124
+ # Ubuntu 18.04, 16.04, earlier
125
+ PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.0"
126
+ fi
127
+ fi
128
+
129
+ echo "Packages to verify are installed: ${PACKAGE_LIST}"
130
+ apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
131
+
132
+ PACKAGES_ALREADY_INSTALLED="true"
133
+ fi
134
+
135
+ # Get to latest versions of all packages
136
+ if [ "${UPGRADE_PACKAGES}" = "true" ]; then
137
+ apt-get-update-if-needed
138
+ apt-get -y upgrade --no-install-recommends
139
+ apt-get autoremove -y
140
+ fi
141
+
142
+ # Ensure at least the en_US.UTF-8 UTF-8 locale is available.
143
+ # Common need for both applications and things like the agnoster ZSH theme.
144
+ if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
145
+ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
146
+ locale-gen
147
+ LOCALE_ALREADY_SET="true"
148
+ fi
149
+
150
+ # Create or update a non-root user to match UID/GID.
151
+ if id -u ${USERNAME} > /dev/null 2>&1; then
152
+ # User exists, update if needed
153
+ if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then
154
+ groupmod --gid $USER_GID $USERNAME
155
+ usermod --gid $USER_GID $USERNAME
156
+ fi
157
+ if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
158
+ usermod --uid $USER_UID $USERNAME
159
+ fi
160
+ else
161
+ # Create user
162
+ if [ "${USER_GID}" = "automatic" ]; then
163
+ groupadd $USERNAME
164
+ else
165
+ groupadd --gid $USER_GID $USERNAME
166
+ fi
167
+ if [ "${USER_UID}" = "automatic" ]; then
168
+ useradd -s /bin/bash --gid $USERNAME -m $USERNAME
169
+ else
170
+ useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
171
+ fi
172
+ fi
173
+
174
+ # Add add sudo support for non-root user
175
+ if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then
176
+ echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
177
+ chmod 0440 /etc/sudoers.d/$USERNAME
178
+ EXISTING_NON_ROOT_USER="${USERNAME}"
179
+ fi
180
+
181
+ # ** Shell customization section **
182
+ if [ "${USERNAME}" = "root" ]; then
183
+ USER_RC_PATH="/root"
184
+ else
185
+ USER_RC_PATH="/home/${USERNAME}"
186
+ fi
187
+
188
+ # .bashrc/.zshrc snippet
189
+ RC_SNIPPET="$(cat << EOF
190
+ export USER=\$(whoami)
191
+ if [[ "\${PATH}" != *"\$HOME/.local/bin"* ]]; then export PATH="\${PATH}:\$HOME/.local/bin"; fi
192
+ EOF
193
+ )"
194
+
195
+ # code shim, it fallbacks to code-insiders if code is not available
196
+ cat << 'EOF' > /usr/local/bin/code
197
+ #!/bin/sh
198
+
199
+ get_in_path_except_current() {
200
+ which -a "$1" | grep -A1 "$0" | grep -v "$0"
201
+ }
202
+
203
+ code="$(get_in_path_except_current code)"
204
+
205
+ if [ -n "$code" ]; then
206
+ exec "$code" "$@"
207
+ elif [ "$(command -v code-insiders)" ]; then
208
+ exec code-insiders "$@"
209
+ else
210
+ echo "code or code-insiders is not installed" >&2
211
+ exit 127
212
+ fi
213
+ EOF
214
+ chmod +x /usr/local/bin/code
215
+
216
+ # Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
217
+ CODESPACES_BASH="$(cat \
218
+ <<EOF
219
+ #!/usr/bin/env bash
220
+ prompt() {
221
+ if [ "\$?" != "0" ]; then
222
+ local arrow_color=\${bold_red}
223
+ else
224
+ local arrow_color=\${reset_color}
225
+ fi
226
+ if [ ! -z "\${GITHUB_USER}" ]; then
227
+ local USERNAME="@\${GITHUB_USER}"
228
+ else
229
+ local USERNAME="\\u"
230
+ fi
231
+ local cwd="\$(pwd | sed "s|^\${HOME}|~|")"
232
+ PS1="\${green}\${USERNAME} \${arrow_color}➜\${reset_color} \${bold_blue}\${cwd}\${reset_color} \$(scm_prompt_info)\${white}$ \${reset_color}"
233
+
234
+ # Prepend Python virtual env version to prompt
235
+ if [[ -n \$VIRTUAL_ENV ]]; then
236
+ if [ -z "\${VIRTUAL_ENV_DISABLE_PROMPT:-}" ]; then
237
+ PS1="(\`basename \"\$VIRTUAL_ENV\"\`) \${PS1:-}"
238
+ fi
239
+ fi
240
+ }
241
+
242
+ SCM_THEME_PROMPT_PREFIX="\${reset_color}\${cyan}(\${bold_red}"
243
+ SCM_THEME_PROMPT_SUFFIX="\${reset_color} "
244
+ SCM_THEME_PROMPT_DIRTY=" \${bold_yellow}✗\${reset_color}\${cyan})"
245
+ SCM_THEME_PROMPT_CLEAN="\${reset_color}\${cyan})"
246
+ SCM_GIT_SHOW_MINIMAL_INFO="true"
247
+ safe_append_prompt_command prompt
248
+ EOF
249
+ )"
250
+ CODESPACES_ZSH="$(cat \
251
+ <<EOF
252
+ prompt() {
253
+ if [ ! -z "\${GITHUB_USER}" ]; then
254
+ local USERNAME="@\${GITHUB_USER}"
255
+ else
256
+ local USERNAME="%n"
257
+ fi
258
+ PROMPT="%{\$fg[green]%}\${USERNAME} %(?:%{\$reset_color%}➜ :%{\$fg_bold[red]%}➜ )"
259
+ PROMPT+='%{\$fg_bold[blue]%}%~%{\$reset_color%} \$(git_prompt_info)%{\$fg[white]%}$ %{\$reset_color%}'
260
+ }
261
+ ZSH_THEME_GIT_PROMPT_PREFIX="%{\$fg_bold[cyan]%}(%{\$fg_bold[red]%}"
262
+ ZSH_THEME_GIT_PROMPT_SUFFIX="%{\$reset_color%} "
263
+ ZSH_THEME_GIT_PROMPT_DIRTY=" %{\$fg_bold[yellow]%}✗%{\$fg_bold[cyan]%})"
264
+ ZSH_THEME_GIT_PROMPT_CLEAN="%{\$fg_bold[cyan]%})"
265
+ prompt
266
+ EOF
267
+ )"
268
+
269
+ # Adapted Oh My Zsh! install step to work with both "Oh Mys" rather than relying on an installer script
270
+ # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for offical script.
271
+ install-oh-my()
272
+ {
273
+ local OH_MY=$1
274
+ local OH_MY_INSTALL_DIR="${USER_RC_PATH}/.oh-my-${OH_MY}"
275
+ local TEMPLATE="${OH_MY_INSTALL_DIR}/templates/$2"
276
+ local OH_MY_GIT_URL=$3
277
+ local USER_RC_FILE="${USER_RC_PATH}/.${OH_MY}rc"
278
+
279
+ if [ -d "${OH_MY_INSTALL_DIR}" ] || [ "${INSTALL_OH_MYS}" != "true" ]; then
280
+ return 0
281
+ fi
282
+
283
+ umask g-w,o-w
284
+ mkdir -p ${OH_MY_INSTALL_DIR}
285
+ git clone --depth=1 \
286
+ -c core.eol=lf \
287
+ -c core.autocrlf=false \
288
+ -c fsck.zeroPaddedFilemode=ignore \
289
+ -c fetch.fsck.zeroPaddedFilemode=ignore \
290
+ -c receive.fsck.zeroPaddedFilemode=ignore \
291
+ ${OH_MY_GIT_URL} ${OH_MY_INSTALL_DIR} 2>&1
292
+ echo -e "$(cat "${TEMPLATE}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE}
293
+ if [ "${OH_MY}" = "bash" ]; then
294
+ sed -i -e 's/OSH_THEME=.*/OSH_THEME="codespaces"/g' ${USER_RC_FILE}
295
+ mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes/codespaces
296
+ echo "${CODESPACES_BASH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces/codespaces.theme.sh
297
+ else
298
+ sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE}
299
+ mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes
300
+ echo "${CODESPACES_ZSH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme
301
+ fi
302
+ # Shrink git while still enabling updates
303
+ cd ${OH_MY_INSTALL_DIR}
304
+ git repack -a -d -f --depth=1 --window=1
305
+
306
+ if [ "${USERNAME}" != "root" ]; then
307
+ cp -rf ${USER_RC_FILE} ${OH_MY_INSTALL_DIR} /root
308
+ chown -R ${USERNAME}:${USERNAME} ${USER_RC_PATH}
309
+ fi
310
+ }
311
+
312
+ if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
313
+ echo "${RC_SNIPPET}" >> /etc/bash.bashrc
314
+ RC_SNIPPET_ALREADY_ADDED="true"
315
+ fi
316
+ install-oh-my bash bashrc.osh-template https://github.com/ohmybash/oh-my-bash
317
+
318
+ # Optionally install and configure zsh and Oh My Zsh!
319
+ if [ "${INSTALL_ZSH}" = "true" ]; then
320
+ if ! type zsh > /dev/null 2>&1; then
321
+ apt-get-update-if-needed
322
+ apt-get install -y zsh
323
+ fi
324
+ if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
325
+ echo "${RC_SNIPPET}" >> /etc/zsh/zshrc
326
+ ZSH_ALREADY_INSTALLED="true"
327
+ fi
328
+ install-oh-my zsh zshrc.zsh-template https://github.com/ohmyzsh/ohmyzsh
329
+ fi
330
+
331
+ # Write marker file
332
+ mkdir -p "$(dirname "${MARKER_FILE}")"
333
+ echo -e "\
334
+ PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
335
+ LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
336
+ EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\
337
+ RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\
338
+ ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
339
+
340
+ echo "Done!"
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env bash
2
+ #-------------------------------------------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5
+ #-------------------------------------------------------------------------------------------------------------
6
+ #
7
+ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/docker.md
8
+ #
9
+ # Syntax: ./docker-debian.sh [enable non-root docker socket access flag] [source socket] [target socket] [non-root user] [use moby]
10
+
11
+ ENABLE_NONROOT_DOCKER=${1:-"true"}
12
+ SOURCE_SOCKET=${2:-"/var/run/docker-host.sock"}
13
+ TARGET_SOCKET=${3:-"/var/run/docker.sock"}
14
+ USERNAME=${4:-"automatic"}
15
+ USE_MOBY=${5:-"true"}
16
+
17
+ set -e
18
+
19
+ if [ "$(id -u)" -ne 0 ]; then
20
+ echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
21
+ exit 1
22
+ fi
23
+
24
+ # Determine the appropriate non-root user
25
+ if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
26
+ USERNAME=""
27
+ POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
28
+ for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
29
+ if id -u ${CURRENT_USER} > /dev/null 2>&1; then
30
+ USERNAME=${CURRENT_USER}
31
+ break
32
+ fi
33
+ done
34
+ if [ "${USERNAME}" = "" ]; then
35
+ USERNAME=root
36
+ fi
37
+ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
38
+ USERNAME=root
39
+ fi
40
+
41
+ # Function to run apt-get if needed
42
+ apt-get-update-if-needed()
43
+ {
44
+ if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
45
+ echo "Running apt-get update..."
46
+ apt-get update
47
+ else
48
+ echo "Skipping apt-get update."
49
+ fi
50
+ }
51
+
52
+ # Ensure apt is in non-interactive to avoid prompts
53
+ export DEBIAN_FRONTEND=noninteractive
54
+
55
+ # Install apt-transport-https, curl, lsb-release, gpg if missing
56
+ if ! dpkg -s apt-transport-https curl ca-certificates lsb-release > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then
57
+ apt-get-update-if-needed
58
+ apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
59
+ fi
60
+
61
+ # Install Docker / Moby CLI if not already installed
62
+ if type docker > /dev/null 2>&1; then
63
+ echo "Docker / Moby CLI already installed."
64
+ else
65
+ if [ "${USE_MOBY}" = "true" ]; then
66
+ DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
67
+ CODENAME=$(lsb_release -cs)
68
+ curl -s https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT)
69
+ echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
70
+ apt-get update
71
+ apt-get -y install --no-install-recommends moby-cli
72
+ else
73
+ curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT)
74
+ echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
75
+ apt-get update
76
+ apt-get -y install --no-install-recommends docker-ce-cli
77
+ fi
78
+ fi
79
+
80
+ # Install Docker Compose if not already installed
81
+ if type docker-compose > /dev/null 2>&1; then
82
+ echo "Docker Compose already installed."
83
+ else
84
+ LATEST_COMPOSE_VERSION=$(curl -sSL "https://api.github.com/repos/docker/compose/releases/latest" | grep -o -P '(?<="tag_name": ").+(?=")')
85
+ curl -sSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
86
+ chmod +x /usr/local/bin/docker-compose
87
+ fi
88
+
89
+ # If init file already exists, exit
90
+ if [ -f "/usr/local/share/docker-init.sh" ]; then
91
+ exit 0
92
+ fi
93
+
94
+ # By default, make the source and target sockets the same
95
+ if [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ]; then
96
+ touch "${SOURCE_SOCKET}"
97
+ ln -s "${SOURCE_SOCKET}" "${TARGET_SOCKET}"
98
+ fi
99
+
100
+ # Add a stub if not adding non-root user access, user is root
101
+ if [ "${ENABLE_NONROOT_DOCKER}" = "false" ] || [ "${USERNAME}" = "root" ]; then
102
+ echo '/usr/bin/env bash -c "\$@"' > /usr/local/share/docker-init.sh
103
+ chmod +x /usr/local/share/docker-init.sh
104
+ exit 0
105
+ fi
106
+
107
+ # If enabling non-root access and specified user is found, setup socat and add script
108
+ chown -h "${USERNAME}":root "${TARGET_SOCKET}"
109
+ if ! dpkg -s socat > /dev/null 2>&1; then
110
+ apt-get-update-if-needed
111
+ apt-get -y install socat
112
+ fi
113
+ tee /usr/local/share/docker-init.sh > /dev/null \
114
+ << EOF
115
+ #!/usr/bin/env bash
116
+ #-------------------------------------------------------------------------------------------------------------
117
+ # Copyright (c) Microsoft Corporation. All rights reserved.
118
+ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
119
+ #-------------------------------------------------------------------------------------------------------------
120
+
121
+ set -e
122
+
123
+ SOCAT_PATH_BASE=/tmp/vscr-dind-socat
124
+ SOCAT_LOG=\${SOCAT_PATH_BASE}.log
125
+ SOCAT_PID=\${SOCAT_PATH_BASE}.pid
126
+
127
+ # Wrapper function to only use sudo if not already root
128
+ sudoIf()
129
+ {
130
+ if [ "\$(id -u)" -ne 0 ]; then
131
+ sudo "\$@"
132
+ else
133
+ "\$@"
134
+ fi
135
+ }
136
+
137
+ # Log messages
138
+ log()
139
+ {
140
+ echo -e "[\$(date)] \$@" | sudoIf tee -a \${SOCAT_LOG} > /dev/null
141
+ }
142
+
143
+ echo -e "\n** \$(date) **" | sudoIf tee -a \${SOCAT_LOG} > /dev/null
144
+ log "Ensuring ${USERNAME} has access to ${SOURCE_SOCKET} via ${TARGET_SOCKET}"
145
+
146
+ # If enabled, try to add a docker group with the right GID. If the group is root,
147
+ # fall back on using socat to forward the docker socket to another unix socket so
148
+ # that we can set permissions on it without affecting the host.
149
+ if [ "${ENABLE_NONROOT_DOCKER}" = "true" ] && [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ] && [ "${USERNAME}" != "root" ] && [ "${USERNAME}" != "0" ]; then
150
+ SOCKET_GID=\$(stat -c '%g' ${SOURCE_SOCKET})
151
+ if [ "\${SOCKET_GID}" != "0" ]; then
152
+ log "Adding user to group with GID \${SOCKET_GID}."
153
+ if [ "\$(cat /etc/group | grep :\${SOCKET_GID}:)" = "" ]; then
154
+ sudoIf groupadd --gid \${SOCKET_GID} docker-host
155
+ fi
156
+ # Add user to group if not already in it
157
+ if [ "\$(id ${USERNAME} | grep -E 'groups=.+\${SOCKET_GID}\(')" = "" ]; then
158
+ sudoIf usermod -aG \${SOCKET_GID} ${USERNAME}
159
+ fi
160
+ else
161
+ # Enable proxy if not already running
162
+ if [ ! -f "\${SOCAT_PID}" ] || ! ps -p \$(cat \${SOCAT_PID}) > /dev/null; then
163
+ log "Enabling socket proxy."
164
+ log "Proxying ${SOURCE_SOCKET} to ${TARGET_SOCKET} for vscode"
165
+ sudoIf rm -rf ${TARGET_SOCKET}
166
+ (sudoIf socat UNIX-LISTEN:${TARGET_SOCKET},fork,mode=660,user=${USERNAME} UNIX-CONNECT:${SOURCE_SOCKET} 2>&1 | sudoIf tee -a \${SOCAT_LOG} > /dev/null & echo "\$!" | sudoIf tee \${SOCAT_PID} > /dev/null)
167
+ else
168
+ log "Socket proxy already running."
169
+ fi
170
+ fi
171
+ log "Success"
172
+ fi
173
+
174
+ # Execute whatever commands were passed in (if any). This allows us
175
+ # to set this script to ENTRYPOINT while still executing the default CMD.
176
+ set +e
177
+ exec "\$@"
178
+ EOF
179
+ chmod +x /usr/local/share/docker-init.sh
180
+ chown ${USERNAME}:root /usr/local/share/docker-init.sh
181
+ echo "Done!"
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ ruby-version: ['2.6', '2.7', '3.0']
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
22
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
23
+ # uses: ruby/setup-ruby@v1
24
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
28
+ - name: MongoDB in GitHub Actions
29
+ # You may pin to the exact commit or the version.
30
+ # uses: supercharge/mongodb-github-action@310bd1bbeb878d9de3e54ee492cbd9643b1e8875
31
+ uses: supercharge/mongodb-github-action@1.3.0
32
+ with:
33
+ mongodb-version: '4.4'
34
+ - name: Run tests
35
+ run: bundle exec rake spec
@@ -0,0 +1,18 @@
1
+ name: Publish to RubyGems.org
2
+ on:
3
+ push:
4
+ tags:
5
+ - '*'
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: '3.0'
15
+ - name: Publish to RubyGems.org
16
+ uses: dawidd6/action-publish-gem@v1
17
+ with:
18
+ api_key: ${{ secrets.RUBYGEMS_API_KEY }}
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mongodb.gemspec
4
4
  gemspec
5
-
6
- gem 'tdiary', github: 'tdiary/tdiary-core'
data/README.md CHANGED
@@ -4,7 +4,7 @@ mongoid adapter for tDiary
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your tDiary's Gemfile.local:
8
8
 
9
9
  gem 'tdiary-io-mongodb'
10
10
 
@@ -12,10 +12,6 @@ And then execute:
12
12
 
13
13
  $ bundle
14
14
 
15
- Or install it yourself as:
16
-
17
- $ gem install tdiary-io-mongodb
18
-
19
15
  ## Usage
20
16
 
21
17
  Add follow snipet to your tdiary.conf
@@ -24,6 +20,45 @@ Add follow snipet to your tdiary.conf
24
20
  @io_class = TDiary::IO::MongoDB
25
21
  ```
26
22
 
23
+ ## Migration
24
+
25
+ `bin/tdiary-mongodb-convert` is utility that uploads tDiary default IO data to MongoDB.
26
+
27
+ (1) Migrate tDiary configuration
28
+
29
+ Migrate your tDiary configuration to MongoDB.
30
+
31
+ ```
32
+ $ bundle exec tdiary-mongodb-convert -c $DATA_PATH/tdiary.conf -m $MONGODB_URI
33
+ ```
34
+
35
+ * $MONGODB_URI: the uri of mongodb (mongodb://)
36
+ * $DATA_PATH: the path of your tdiary data directory
37
+
38
+ (2) Migrate tDiary data
39
+
40
+ Migrate your tDiary data to MongoDB.
41
+
42
+ ```
43
+ $ bundle exec tdiary-mongodb-convert -s ./lib/tdiary/style -m $MONGODB_URI $DATA_PATH
44
+ ```
45
+ * $MONGODB_URI: the uri of mongodb (mongodb://)
46
+ * $DATA_PATH: the path of your tdiary data directory
47
+
48
+ ### Note
49
+
50
+ If you use the style provided by an external gem (like GFM style), append the gem to Gemfile and run `bundle`.
51
+
52
+ ```
53
+ gem 'tdiary-style-gfm'
54
+ gem 'tdiary-style-etdiary'
55
+ gem 'tdiary-style-rd
56
+ ```
57
+
58
+ ### See also
59
+
60
+ * http://sho.tdiary.net/20150206.html#p01 (in Japanese)
61
+
27
62
  ## Contributing
28
63
 
29
64
  1. Fork it
@@ -31,7 +31,7 @@ module TDiary
31
31
  include Mongoid::Timestamps
32
32
  store_in collection: "comments"
33
33
 
34
- belongs_to :diary
34
+ belongs_to :diary, class_name: 'TDiary::IO::MongoDB::Diary'
35
35
  field :name, type: String
36
36
  field :mail, type: String
37
37
  field :body, type: String
@@ -61,8 +61,8 @@ module TDiary
61
61
  field :style, type: String
62
62
  field :last_modified, type: Integer
63
63
  field :visible, type: Boolean
64
- has_many :comments, autosave: true
65
- has_many :referers, autosave: true
64
+ has_many :comments, autosave: true, class_name: 'TDiary::IO::MongoDB::Comment'
65
+ has_many :referers, autosave: true, class_name: 'TDiary::IO::MongoDB::Referer'
66
66
 
67
67
  index({diary_id: 1}, {unique: true})
68
68
  index({year: 1, month: 1})
@@ -110,6 +110,8 @@ module TDiary
110
110
  include Cache
111
111
 
112
112
  class << self
113
+ Mongo::Logger.level = Logger::WARN
114
+
113
115
  def load_cgi_conf(conf)
114
116
  db(conf)
115
117
  if cgi_conf = Conf.all.first
@@ -131,7 +133,7 @@ module TDiary
131
133
 
132
134
  def db(conf)
133
135
  @@_db ||= Mongoid::Config.load_configuration(
134
- {sessions:{default:{uri:(conf.database_url || 'mongodb://localhost:27017/tdiary')}}}
136
+ {clients:{default:{uri:(conf.database_url || 'mongodb://localhost:27017/tdiary')}}}
135
137
  )
136
138
  end
137
139
 
@@ -181,9 +183,15 @@ module TDiary
181
183
  end
182
184
 
183
185
  def calendar
186
+ mongo_project = {
187
+ "$group" => {
188
+ "_id" => {"year" => "$year", "month" => "$month"},
189
+ "count" => {"$sum" => 1}
190
+ }
191
+ }
184
192
  calendar = Hash.new{|hash, key| hash[key] = []}
185
- Diary.all.map{|d|[d.year, d.month]}.sort.uniq.each do |ym|
186
- calendar[ym[0]] << ym[1]
193
+ Diary.collection.aggregate([mongo_project]).map do |cal|
194
+ calendar[cal['_id']['year']] << cal['_id']['month']
187
195
  end
188
196
  calendar
189
197
  end
data/spec/spec_helper.rb CHANGED
@@ -37,7 +37,7 @@ end
37
37
 
38
38
  class DummyConf
39
39
  def database_url
40
- 'mongodb://localhost:27017/tdiary_test'
40
+ ENV['MONGODB_URI'] || 'mongodb://localhost:27017/tdiary_test'
41
41
  end
42
42
 
43
43
  def cache_path
@@ -83,7 +83,7 @@ end
83
83
 
84
84
  RSpec.configure do |c|
85
85
  c.after(:suite) do
86
- Mongoid.default_session.collections.each do |collection|
86
+ Mongoid.default_client.database.collections.each do |collection|
87
87
  collection.drop
88
88
  end
89
89
  end
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "tdiary-io-mongodb"
7
- spec.version = "4.1.2"
8
- spec.authors = ["TADA Tadashi"]
7
+ spec.version = "5.1.1"
8
+ spec.authors = ["Tada, Tadashi"]
9
9
  spec.email = ["t@tdtds.jp"]
10
10
  spec.description = %q{MongoDB adapter for tDiary}
11
11
  spec.summary = %q{MongoDB adapter for tDiary}
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "mongoid"
20
+ spec.add_dependency "mongoid", "~> 7.2"
21
+ spec.add_dependency "mongo", "~> 2.14"
21
22
  spec.add_dependency "hikidoc"
23
+ spec.add_dependency "tdiary", ">= 5.0"
22
24
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "bundler"
24
26
  spec.add_development_dependency "rake"
25
27
  spec.add_development_dependency "rspec"
26
28
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,17 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-io-mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - TADA Tadashi
7
+ - Tada, Tadashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mongo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.14'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hikidoc
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
@@ -25,33 +53,33 @@ dependencies:
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
- name: hikidoc
56
+ name: tdiary
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - ">="
32
60
  - !ruby/object:Gem::Version
33
- version: '0'
61
+ version: '5.0'
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - ">="
39
67
  - !ruby/object:Gem::Version
40
- version: '0'
68
+ version: '5.0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '1.3'
75
+ version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '1.3'
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rake
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -102,8 +130,14 @@ executables:
102
130
  extensions: []
103
131
  extra_rdoc_files: []
104
132
  files:
133
+ - ".devcontainer/Dockerfile"
134
+ - ".devcontainer/devcontainer.json"
135
+ - ".devcontainer/docker-compose.yml"
136
+ - ".devcontainer/library-scripts/common-debian.sh"
137
+ - ".devcontainer/library-scripts/docker-debian.sh"
138
+ - ".github/workflows/ci.yml"
139
+ - ".github/workflows/release.yml"
105
140
  - ".gitignore"
106
- - ".travis.yml"
107
141
  - Gemfile
108
142
  - LICENSE.txt
109
143
  - README.md
@@ -133,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
167
  - !ruby/object:Gem::Version
134
168
  version: '0'
135
169
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.4.5
170
+ rubygems_version: 3.2.15
138
171
  signing_key:
139
172
  specification_version: 4
140
173
  summary: MongoDB adapter for tDiary
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1
6
- script: bundle exec rake spec
7
- services:
8
- - mongodb