-
Notifications
You must be signed in to change notification settings - Fork 0
Tweaks for Sofatutor #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
dea294c
1579d20
10e15fe
3651b58
8ebf31d
6c12605
666bd1f
a68764c
65efb50
4a346a2
96b8eca
6839b54
9c93a0e
345077b
e7c19ac
82954fa
6cbe1f9
618d7b3
1efb4d5
bf6acb7
3da00b8
ec6c42e
2fe79a2
b78016f
ad36e4c
f9e1bf0
c40d19e
f2de689
2bf4bf3
decb5bb
f3bad2b
3ed7e53
38f7d30
b667a40
06bb0c0
85642f3
1483247
b721463
01893ab
28f2978
1300b80
6fa534a
f0febba
f8d0df1
d813738
0d4ea75
94ece4a
851f290
65e4b55
754217e
9a4aa56
53439df
7d22102
8b1ede9
e2c5c61
0ed4c7f
5e97620
026a9a0
6ba17f8
77a54a5
171df05
1d82eda
7a352aa
0357b59
5858073
c2e99a5
1e14c30
2de72ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # This workflow uses actions that are not certified by GitHub. | ||
| # They are provided by a third-party and are governed by | ||
| # separate terms of service, privacy policy, and support | ||
| # documentation. | ||
|
|
||
| # GitHub recommends pinning actions to a commit SHA. | ||
| # To get a newer version, you will need to update the SHA. | ||
| # You can also reference a tag or branch, but the action may change without warning. | ||
| --- | ||
| name: Create and publish a Container image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - sofatutor | ||
| tags: | ||
| - "v*" | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.event.repository.owner.name }}/pullpreview | ||
|
|
||
| jobs: | ||
| build-and-push-image: | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Log in to the Container registry | ||
| uses: sofatutor/docker-login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: sofatutor/docker-metadata-action@57396166ad8aefe6098280995947635806a0e6ea | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: sofatutor/docker-build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 | ||
| with: | ||
| context: . | ||
| push: true | ||
| pull: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ inputs: | |
| ports: | ||
| description: "Ports to open for external access on the preview server (port 22 is always open), comma-separated" | ||
| required: false | ||
| default: "80/tcp,443/tcp,1000-10000/tcp" | ||
| default: "80/tcp,443/tcp" | ||
| cidrs: | ||
| description: "The IP address, or range of IP addresses in CIDR notation, that are allowed to connect to the instance" | ||
| required: false | ||
|
|
@@ -46,6 +46,10 @@ inputs: | |
| description: "Names of private registries to authenticate against. E.g. docker://username:password@ghcr.io" | ||
| required: false | ||
| default: "" | ||
| deploy_key: | ||
| description: "Additional public SSH key used for authentication" | ||
| required: false | ||
| default: "" | ||
|
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
|
|
||
| outputs: | ||
| url: | ||
|
|
@@ -57,7 +61,7 @@ outputs: | |
|
|
||
| runs: | ||
| using: "docker" | ||
| image: "Dockerfile" | ||
| image: docker://ghcr.io/sofatutor/pullpreview:sofatutor | ||
| args: | ||
| - "github-sync" | ||
| - "${{ inputs.app_path }}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,14 @@ up_opts = lambda do |o| | |
| o.array '--registries', 'URIs of docker registries to authenticate against, e.g. docker://username:password@ghcr.io', default: [] | ||
| o.string '--dns', 'Enable DNS support for pretty-looking URLs', default: "my.pullpreview.com" | ||
| o.array '--ports', 'Ports to open for external access on the preview server', default: [ | ||
| "80/tcp", "443/tcp", "1000-10000/tcp" | ||
| "80/tcp", "443/tcp" | ||
| ] | ||
| o.string '--instance-type', 'Instance type to use', default: 'small_2_0' | ||
| o.string '--default-port', 'Default port to use when displaying the instance hostname', default: "80" | ||
| o.array '--tags', 'Tags to add to the instance' | ||
| o.array '--compose-files', 'Compose files to use when running docker-compose up', default: ["docker-compose.yml"] | ||
| o.string '--deploy-key', 'Additional public SSH key (optional)' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| o.string '--subdomain', 'Instance subdomain (optional)' | ||
| end | ||
|
|
||
| begin | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ set -o pipefail | |
|
|
||
| APP_TARBALL="$1" | ||
| APP_PATH="<%= locals.remote_app_path %>" | ||
| PULLPREVIEW_LAUNCH_COMMAND="<%= locals.custom_launch_command %>" | ||
| PULLPREVIEW_ENV_VARS="<%= locals.custom_env_vars %>" | ||
| PULLPREVIEW_ENV_FILE="/etc/pullpreview/env" | ||
|
|
||
| lock_file="/tmp/update.lock" | ||
|
|
@@ -51,30 +53,36 @@ echo 'PULLPREVIEW_PUBLIC_IP=<%= locals.public_ip %>' >> $PULLPREVIEW_ENV_FILE | |
| echo 'PULLPREVIEW_URL=<%= locals.url %>' >> $PULLPREVIEW_ENV_FILE | ||
| echo "PULLPREVIEW_FIRST_RUN=$PULLPREVIEW_FIRST_RUN" >> $PULLPREVIEW_ENV_FILE | ||
|
|
||
| if [ -n "${PULLPREVIEW_ENV_VARS}" ] ; then | ||
| while read -d, -r pair; do | ||
| IFS='=' read -r key val <<<"$pair" | ||
| echo "$key=$val" >> $PULLPREVIEW_ENV_FILE | ||
| done <<<"$PULLPREVIEW_ENV_VARS," | ||
| fi | ||
|
|
||
|
Comment on lines
+56
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| set -o allexport | ||
| source $PULLPREVIEW_ENV_FILE | ||
| set +o allexport | ||
|
|
||
| cd / | ||
|
|
||
| sudo rm -rf "$APP_PATH" | ||
| sudo mkdir -p "$APP_PATH" | ||
| sudo chown -R ec2-user.ec2-user "$APP_PATH" | ||
| tar xzf "$1" -C "$APP_PATH" | ||
| sudo rm -rf "/tmp$APP_PATH" | ||
| sudo mkdir -p "$APP_PATH" "/tmp$APP_PATH" | ||
| sudo chown -R ec2-user.ec2-user "$APP_PATH" "/tmp$APP_PATH" | ||
| tar xzf "$1" -C "/tmp$APP_PATH" | ||
| rsync -auz "/tmp$APP_PATH" / --remove-source-files --delete | ||
|
Comment on lines
+69
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be pulled to upstream: Makes sure that |
||
|
|
||
| cd "$APP_PATH" | ||
|
|
||
| echo "Cleaning up..." | ||
| docker volume prune -f || true | ||
|
|
||
| echo "Updating dependencies..." | ||
| yum update -y || true | ||
|
|
||
| if ! /tmp/pre_script.sh ; then | ||
| echo "Failed to run the pre-script" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -n "${PULLPREVIEW_LAUNCH_COMMAND}" ] ; then | ||
| echo "Command to be executed: $PULLPREVIEW_LAUNCH_COMMAND" | ||
| bash -c "$PULLPREVIEW_LAUNCH_COMMAND" ; exit $? | ||
| fi | ||
|
|
||
| pull() { | ||
| docker-compose <%= locals.compose_files.map{|f| ["-f", f.inspect]}.flatten.join(" ") %> pull -q | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be pulled to upstream (security issue)