Skip to content

Commit

Permalink
Remove CONTAINER_ID, add SSH
Browse files Browse the repository at this point in the history
- CONTAINER_ID was only used for Google Optimize, which is discontinued
- SSH will be needed for ongoing maintenance by developers

see https://learn.microsoft.com/en-gb/azure/app-service/configure-custom-container?tabs=alpine&pivots=container-linux#enable-ssh
  • Loading branch information
ebrett committed Oct 13, 2023
1 parent 2242bf7 commit b05dc19
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ RAILS_ENV=development
WEBPACKER_DEV_SERVER_HOST=0.0.0.0
FEEDBACK_URL=
SIGNUP_URL=
TRACKING_ID=
2 changes: 1 addition & 1 deletion .github/workflows/azure-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.sha }}
cache-from: |
type=registry,ref=${{ env.DOCKER_IMAGE }}-prod:latest
type=registry,ref=${{ env.DOCKER_IMAGE }}:latest
push: true
tags: |
${{ env.DOCKER_IMAGE }}:latest
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ COPY --from=assets-precompile /usr/local/bundle/ usr/local/bundle/
# The application runs from /app
WORKDIR /app

COPY sshd_config /etc/ssh/
COPY ./entrypoints/docker-entrypoint.sh ./

# Start and enable SSH
RUN apk add openssh \
&& echo "root:Docker!" | chpasswd \
&& chmod +x ./docker-entrypoint.sh \
&& cd /etc/ssh/ \
&& ssh-keygen -A

EXPOSE 3000 2222

ENTRYPOINT [ "./docker-entrypoint.sh" ]

# Use the following for development testing
CMD bundle exec rails db:migrate && bundle exec rails server -b 0.0.0.0

Expand Down
2 changes: 0 additions & 2 deletions app/views/layouts/_analytics_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<script src="https://www.googleoptimize.com/optimize.js?id=<%= GoogleAnalytics::CONTAINER_ID %>"></script>

<!-- Google tag (gtag.js) -->
<script async src=<%= "https://www.googletagmanager.com/gtag/js?id=#{GoogleAnalytics::TRACKING_ID}" %>></script>
<script>
Expand Down
3 changes: 1 addition & 2 deletions config/initializers/google_analytics.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

module GoogleAnalytics
CONTAINER_ID = Rails.application.credentials.dig :google_analytics, Rails.configuration.space.to_sym, :container_id
TRACKING_ID = Rails.application.credentials.dig :google_analytics, Rails.configuration.space.to_sym, :tracking_id
TRACKING_ID = ENV.fetch("TRACKING_ID", "#TRACKING_ID_env_var_missing")
JS_URL = "https://www.googletagmanager.com/ns.html?id=#{GoogleAnalytics::TRACKING_ID}"
end
2 changes: 2 additions & 0 deletions entrypoints/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi

/usr/sbin/sshd

bundle exec rake db:prepare db:seed

# Start the application
Expand Down
12 changes: 12 additions & 0 deletions sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Port 2222
ListenAddress 0.0.0.0
LoginGraceTime 180
X11Forwarding yes
Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr
MACs hmac-sha1,hmac-sha1-96
StrictModes yes
SyslogFacility DAEMON
PasswordAuthentication yes
PermitEmptyPasswords no
PermitRootLogin yes
Subsystem sftp internal-sftp

0 comments on commit b05dc19

Please sign in to comment.