Skip to content

Commit

Permalink
Ruby 3.2 workspace setting
Browse files Browse the repository at this point in the history
  • Loading branch information
haru committed Aug 26, 2023
1 parent 43c6e4c commit cc36bc1
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 35 deletions.
25 changes: 16 additions & 9 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ ARG VARIANT=2-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}

# Install Rails
RUN gem install rails webdrivers
# RUN gem install rails webdrivers

# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
# The value is a comma-separated list of allowed domains
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev"

# [Choice] Node.js version: lts/*, 16, 14, 12, 10
ARG NODE_VERSION="lts/*"
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
# ARG NODE_VERSION="lts/*"
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
Expand All @@ -24,23 +24,30 @@ RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSI
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

RUN apt-get update
RUN apt-get install -y imagemagick
RUN apt-get install -y imagemagick git-flow

WORKDIR /usr/local
ARG REDMINE_VERSION=master
RUN git clone https://github.com/redmine/redmine.git -b ${REDMINE_VERSION}
WORKDIR /usr/local/redmine
RUN chown -R vscode .
COPY .devcontainer/database.yml /usr/local/redmine/config/database.yml

RUN rm -rf .git
RUN echo "gem 'ruby-debug-ide'" >> Gemfile
RUN echo "gem 'debase'" >> Gemfile
# RUN echo "gem 'ruby-debug-ide'" >> Gemfile
RUN echo "gem 'debug'" >> Gemfile
RUN echo "gem 'rufo'" >> Gemfile
ENV DB=sqlite3
USER vscode
RUN bundle install
RUN bundle exec rake db:migrate
RUN bundle exec rake db:migrate RAILS_ENV=test
COPY .devcontainer/launch.json /usr/local/redmine/.vscode/launch.json
RUN chown -R vscode .
RUN mkdir -p .vscode

USER root

RUN sed -i "s/^end/ config.hosts.clear if config.respond_to?(:hosts)\nend/" config/environments/development.rb

COPY .devcontainer/post-create.sh /post-create.sh

COPY .devcontainer/post-create.sh /post-create.sh
WORKDIR /workspaces
20 changes: 16 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"dockerComposeFile": "docker-compose.yml",
"service": "app",

"workspaceFolder": "/usr/local/redmine",
"mounts": [
"source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind"
],
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// "workspaceFolder": "/workspaces/dev.code-workspace",

// Set *default* container specific settings.json values on container create.
"settings": {
Expand Down Expand Up @@ -45,7 +49,11 @@
"hridoy.rails-snippets",
"misogi.ruby-rubocop",
"jnbt.vscode-rufo",
"donjayamanne.git-extension-pack"
"donjayamanne.git-extension-pack",
"ms-azuretools.vscode-docker",
"KoichiSasada.vscode-rdbg",
"Serhioromano.vscode-gitflow",
"github.vscode-github-actions"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand All @@ -58,7 +66,11 @@
"remoteUser": "vscode",
"features": {
// "git": "latest"
}
},


"containerEnv": {
"PLUGIN_NAME": "${localWorkspaceFolderBasename}"
},

"forwardPorts": [3000]
}
3 changes: 0 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ services:
NODE_VERSION: "lts/*"
REDMINE_VERSION: "5.0-stable"

volumes:
- ..:/usr/local/redmine/plugins/redmine_wiki_extensions:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

Expand Down
45 changes: 27 additions & 18 deletions .devcontainer/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,69 @@

{
"name": "Rails server",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
]
},
{
"name": "Rails server(postgres)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
],
"env":{
"DB": "postgres"
}
},
{
"name": "Rails server(mysql)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"command": "${workspaceRoot}/bin/rails",
"script": "server",
"useBundler": true,
"args": [
"server"
"-b",
"0.0.0.0"
],
"env":{
"DB": "mysql"
}
},
{
"name": "Plugin Test",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
"env":{
"RAILS_ENV": "test"
}
},
{
"name": "Plugin Test(postgres)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
"env":{
"RAILS_ENV": "test",
Expand All @@ -68,12 +76,13 @@
},
{
"name": "Plugin Test(mysql)",
"type": "Ruby",
"type": "rdbg",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"command": "${workspaceRoot}/bin/rake",
"script": "redmine:plugins:test",
"useBundler": true,
"cwd": "${workspaceRoot}",
"args": [
"redmine:plugins:test"
],
"env":{
"RAILS_ENV": "test",
Expand Down
11 changes: 10 additions & 1 deletion .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/sh
cd /usr/local/redmine

cp plugins/redmine_wiki_extensions/Gemfile_for_test plugins/redmine_wiki_extensions/Gemfile
ln -s /workspaces/${PLUGIN_NAME} plugins/${PLUGIN_NAME}
if [ -f plugins/${PLUGIN_NAME}/Gemfile_for_test ]
then
cp plugins/${PLUGIN_NAME}/Gemfile_for_test plugins/${PLUGIN_NAME}/Gemfile
fi
cp plugins/${PLUGIN_NAME}/test/fixtures/*.yml test/fixtures
ln -s /workspaces/${PLUGIN_NAME}/.devcontainer/launch.json .vscode/launch.json

bundle install
bundle exec rake redmine:plugins:migrate
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
Expand All @@ -17,6 +24,8 @@ initdb() {
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
}

initdb

export DB=postgres

initdb
Expand Down
11 changes: 11 additions & 0 deletions .redmine.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../../usr/local/redmine"
}
],
"settings": {}
}

0 comments on commit cc36bc1

Please sign in to comment.