Skip to content

Commit 540efd6

Browse files
author
github-actions
committed
update with project-syncing action
1 parent 5cb6a94 commit 540efd6

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Container",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "firstdraft/appdev-rails-template",
6+
"image": "firstdraft/appdev-rails-7-template",
77

88
// Features to add to the dev container. More info: https://containers.dev/features.
99
// "features": {},

appdev.rails7.Dockerfile

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
FROM ubuntu:focal
2+
3+
### base ###
4+
ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8
5+
RUN yes | unminimize \
6+
&& apt-get install -yq \
7+
curl \
8+
wget \
9+
acl \
10+
zip \
11+
unzip \
12+
bash-completion \
13+
build-essential \
14+
jq \
15+
locales \
16+
software-properties-common \
17+
libpq-dev \
18+
sudo \
19+
git \
20+
graphviz=2.42.2-3build2 \
21+
psmisc \
22+
redis-server=5:5.0.7-2ubuntu0.1 \
23+
&& locale-gen en_US.UTF-8 \
24+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* \
25+
# Container user
26+
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
27+
&& useradd -l -u 33334 -G sudo -md /home/student -s /bin/bash -p student student \
28+
# Passwordless sudo for users in the 'sudo' group
29+
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers
30+
ENV HOME=/home/student
31+
32+
### Student user ###
33+
USER student
34+
# Use sudo so that user does not get sudo usage info on (the first) login
35+
RUN sudo mkdir -p $HOME \
36+
&& sudo echo "Running 'sudo' for container: success" && \
37+
# Create .bashrc.d folder and source it in the bashrc
38+
mkdir /home/student/.bashrc.d && \
39+
(echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/student/.bashrc \
40+
# Install Ruby with RVM
41+
&& curl -sSL https://rvm.io/mpapis.asc | gpg --import - \
42+
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - \
43+
&& curl -fsSL https://get.rvm.io | bash -s stable \
44+
&& bash -lc " \
45+
rvm requirements \
46+
&& rvm install 3.2.1 \
47+
&& rvm use 3.2.1 --default \
48+
&& rvm rubygems current \
49+
&& gem install bundler:2.4.6 --no-document" \
50+
&& echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> /home/student/.bashrc.d/70-ruby && echo "rvm_gems_path=/home/student/.rvm" > ~/.rvmrc
51+
52+
ENV GEM_HOME=/workspaces/.rvm PATH=/workspaces/.rvm/bin:$PATH
53+
54+
WORKDIR /rails-template
55+
56+
# Pre-install gems into /rails-template/gems/
57+
COPY --chown=student:student Gemfile Gemfile.lock /rails-template/
58+
RUN /bin/bash -l -c "bundle install" \
59+
# Install postgresql 16
60+
&& sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt `lsb_release -cs`-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
61+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - \
62+
&& sudo apt-get update \
63+
&& sudo apt-get install -y postgresql-16 postgresql-contrib-16
64+
65+
# Setup PostgreSQL configuration
66+
ENV PATH="$PATH:/usr/lib/postgresql/16/bin" PGDATA="/workspaces/.pgsql/data"
67+
RUN sudo mkdir -p $PGDATA \
68+
&& mkdir -p ~/.pg_ctl/bin ~/.pg_ctl/sockets \
69+
&& printf '#!/bin/bash\n[ ! -d $PGDATA ] && mkdir -p $PGDATA && initdb -D $PGDATA\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n' > ~/.pg_ctl/bin/pg_start \
70+
&& printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n' > ~/.pg_ctl/bin/pg_stop \
71+
&& chmod +x ~/.pg_ctl/bin/* \
72+
&& sudo addgroup dev \
73+
&& sudo adduser student dev \
74+
&& sudo chgrp -R dev $PGDATA \
75+
&& sudo chmod -R 775 $PGDATA \
76+
&& sudo setfacl -dR -m g:staff:rwx $PGDATA \
77+
&& sudo chmod 777 /var/run/postgresql \
78+
# This is a bit of a hack. At the moment we have no means of starting background
79+
# tasks from a Dockerfile. This workaround checks, on each bashrc eval, if the
80+
# PostgreSQL server is running, and if not starts it.
81+
&& printf "\n# Auto-start PostgreSQL server.\n[[ \$(pg_ctl status | grep PID) ]] || pg_start > /dev/null\n" >> ~/.bashrc
82+
ENV PATH="$PATH:$HOME/.pg_ctl/bin" PGHOSTADDR="127.0.0.1" PGDATABASE="postgres"
83+
84+
85+
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - \
86+
# Install Node.js and Yarn
87+
&& sudo apt-get install -y nodejs \
88+
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \
89+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
90+
&& sudo apt-get update \
91+
&& sudo apt-get install -y yarn \
92+
&& sudo npm install -g n \
93+
&& sudo n 18 \
94+
&& hash -r \
95+
&& sudo rm -rf /var/lib/apt/lists/* \
96+
# Add thoughtbot style bash prompt
97+
&& sudo wget -qO ./prompt "https://gist.githubusercontent.com/jelaniwoods/7e5db8d72b3dfac257b7eb562cfebf11/raw/af43083d91c0eb1489059a2ad9c39474a34ddbda/thoughtbot-style-prompt" \
98+
&& /bin/bash -l -c "cat ./prompt >> ~/.bashrc" \
99+
# Set git config
100+
&& git config --global push.default upstream \
101+
&& git config --global merge.ff only \
102+
&& git config --global alias.aa '!git add -A' \
103+
&& git config --global alias.cm '!f(){ git commit -m "${*}"; };f' \
104+
&& git config --global alias.acm '!f(){ git add -A && git commit -am "${*}"; };f' \
105+
&& git config --global alias.as '!git add -A && git stash' \
106+
&& git config --global alias.p 'push' \
107+
&& git config --global alias.sla 'log --oneline --decorate --graph --all' \
108+
&& git config --global alias.co 'checkout' \
109+
&& git config --global alias.cob 'checkout -b' \
110+
&& git config --global --add --bool push.autoSetupRemote true \
111+
&& git config --global core.editor "code --wait" \
112+
# Add g alias for git status
113+
&& echo "# No arguments: 'git status'\n\
114+
# With arguments: acts like 'git'\n\
115+
g() {\n\
116+
if [[ \$# > 0 ]]; then\n\
117+
git \$@\n\
118+
else\n\
119+
git status\n\
120+
fi\n\
121+
}\n# Complete g like git\n\
122+
source /usr/share/bash-completion/completions/git\n\
123+
__git_complete g __git_main" >> ~/.bash_aliases \
124+
# Add other aliases
125+
&& echo "alias be='bundle exec'" >> ~/.bash_aliases \
126+
&& echo "alias grade='rake grade'" >> ~/.bash_aliases \
127+
&& echo "alias grade:reset_token='rake grade:reset_token'" >> ~/.bash_aliases \
128+
&& echo 'export PATH="$PWD/bin:$PATH"' >> ~/.bashrc \
129+
&& echo "nohup /workspaces/*/bin/postgres-monitor > /dev/null 2>&1 &" >> ~/.bashrc

0 commit comments

Comments
 (0)