-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: updates Dockerfile, creates init.sh, updates github actions work…
…flows Also updates the README with developer startup instructions
- Loading branch information
Showing
11 changed files
with
116 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
# | ||
# An example hook script to verify what is about to be committed. | ||
# Called by "git commit" with no arguments. The hook should | ||
# exit with non-zero status after issuing an appropriate message if | ||
# it wants to stop the commit. | ||
# | ||
# To enable this hook, rename this file to "pre-commit". | ||
#!/bin/sh | ||
|
||
set -e | ||
rubyfiles=$(git diff --cached --name-only --diff-filter=ACM "*.rb" "Gemfile" | tr '\n' ' ') | ||
[ -z "$rubyfiles" ] && exit 0 | ||
|
||
# Standardize all ruby files | ||
echo "🧹 Formatting staged Ruby files using standardrb ($(echo $rubyfiles | wc -w | awk '{print $1}') total)" | ||
echo "$rubyfiles" | xargs docker compose run -T --rm web bundle exec standardrb --fix | ||
|
||
# Add back the modified/prettified files to staging | ||
echo "$rubyfiles" | xargs git add | ||
|
||
echo "📋 Running tests with rspec" | ||
docker compose run -T --rm web bundle exec rspec --format progress | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
server/ssh/* | ||
!server/ssh/README.md | ||
Gemfile.lock | ||
.bash_history | ||
|
||
# rspec failure tracking | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
FROM ruby:3.1 | ||
FROM ruby:3.2 | ||
ARG UNAME=app | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ | ||
vim | ||
|
||
RUN gem install bundler:2.3 | ||
RUN gem install bundler | ||
ENV BUNDLE_PATH /gems | ||
ENV PATH="$PATH:/app/exe:/app/bin" | ||
|
||
RUN groupadd -g ${GID} -o ${UNAME} | ||
RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} | ||
RUN mkdir -p /gems && chown ${UID}:${GID} /gems | ||
USER $UNAME | ||
|
||
|
||
WORKDIR /app | ||
COPY --chown=${UID}:${GID} . /app | ||
RUN bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sftp | ||
# SFTP | ||
|
||
This gem wraps shell `sftp` to make working with it in Ruby scripts easier. | ||
|
||
|
@@ -29,7 +29,7 @@ require "sftp" | |
SFTP.configure do |config| | ||
config.user = "your_sftp_user" | ||
config.host = "your_sftp_host" | ||
congig.key_paty = "path/to/your/ssh/key/file" | ||
config.key_path = "path/to/your/ssh/key/file" | ||
end | ||
client = SFTP.client | ||
|
@@ -88,11 +88,48 @@ SFTP.client.ls("directory") | |
## Development | ||
In the application root folder, set up the ssh_keys: | ||
Clone the repo | ||
```bash | ||
git clone [email protected]:mlibrary/account.git | ||
cd account | ||
``` | ||
run the `init.sh` script. This will copy a pre-commit hook for git, build the | ||
container, and set up ssh keys for development. | ||
```bash | ||
./init.sh | ||
``` | ||
start containers | ||
```bash | ||
docker compose up -d | ||
``` | ||
The compose.yml has a fileserver service running sftp. The files are in the | ||
`server/files` directory. | ||
To try out the gem you can run: | ||
```bash | ||
docker compose run --rm app console | ||
SFTP.client.ls | ||
``` | ||
./bin/set_up_development_ssh_keys.sh | ||
This will load the gem in irb, and connect you to the sftp service in compose.yml | ||
### Troubleshooting | ||
If the the `app` service can't connect to the `sftp` service, try restarting by | ||
doing: | ||
```bash | ||
docker compose down | ||
docker compose up -d | ||
``` | ||
The ssh keys volume mounted in may not have been properly copied to | ||
`authorized_keys` in the `fileserver` service, and doing this hard restart will | ||
get the appropriate ones copied in. | ||
## Contributing | ||
Bug reports and pull requests are welcome on GitHub at https://github.com/mlibrary/sftp | ||
Bug reports and pull requests are welcome on GitHub at | ||
https://github.com/mlibraray/sftp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
version: '3' | ||
|
||
services: | ||
web: | ||
app: | ||
build: . | ||
volumes: | ||
- .:/app | ||
- ./server/ssh/ssh_client_rsa_key:/etc/secret-volume/id_rsa:ro | ||
- gem_cache:/gems | ||
env_file: | ||
- .env-dev-values | ||
- env.development | ||
|
||
fileserver: | ||
image: 'atmoz/sftp' | ||
volumes: | ||
- ./server/files:/home/my_user/files | ||
- ./server/ssh/ssh_client_rsa_key.pub:/home/my_user/.ssh/keys/id_rsa.pub:ro | ||
- ./server/ssh/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key | ||
- ./server/ssh/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key | ||
command: my_user:1001 | ||
volumes: | ||
gem_cache: | ||
command: my_user::1001 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
if [ -f ".git/hooks/pre-commit" ]; then | ||
echo "🪝 .git/hooks/pre-commit exists. Leaving alone" | ||
else | ||
echo "🪝 .git/hooks/pre-commit does not exist. Copying .github/pre-commit to .git/hooks/" | ||
cp .github/pre-commit .git/hooks/pre-commit | ||
fi | ||
|
||
echo "🚢 Build docker images" | ||
docker compose build | ||
|
||
echo "🔑 Set up development keys" | ||
./bin/set_up_development_ssh_keys.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"release-type": "ruby", | ||
"bump-minor-pre-major": true, | ||
"packages": { | ||
".": { | ||
"release-type": "ruby", | ||
"package-name": "sftp" | ||
} | ||
} | ||
} |