Skip to content

Commit 69cd7da

Browse files
committed
launchpod buttons and actions
1 parent e83c258 commit 69cd7da

File tree

10 files changed

+485
-0
lines changed

10 files changed

+485
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "LocalStack DinD setup",
3+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
4+
5+
"remoteEnv": {
6+
// Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
7+
"LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required for Pro, not processed via template due to security reasons
8+
"LOCALSTACK_API_KEY": "${localEnv:LOCALSTACK_API_KEY}",
9+
// LocalStack configuration: https://docs.localstack.cloud/references/configuration/
10+
"ACTIVATE_PRO": true,
11+
"DEBUG": true,
12+
"LS_LOG": "trace",
13+
"PERSISTENCE": false,
14+
"AWS_ENDPOINT_URL": "http://localhost.localstack.cloud:4566",
15+
"AUTO_LOAD_POD": "",
16+
"ENFORCE_IAM": false,
17+
"AWS_REGION": "us-east-1",
18+
"AWS_DEFAULT_REGION": "us-east-1",
19+
"IMAGE_NAME": "localstack/localstack-pro:latest",
20+
"LOCALSTACK_VOLUME_DIR": "/data"
21+
},
22+
23+
// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
24+
"features": {
25+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
26+
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
27+
"version": "latest",
28+
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
29+
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
30+
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
31+
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
32+
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
33+
},
34+
"ghcr.io/devcontainers/features/aws-cli:1": {},
35+
"ghcr.io/devcontainers/features/python:1": {
36+
"version": "3.11"
37+
}
38+
},
39+
40+
// 👇 Use 'postCreateCommand' to run commands after the container is created.
41+
"postCreateCommand": "type localstack; true && localstack start -d || true",
42+
"mounts": [
43+
{
44+
// to persist build data and images
45+
"source": "dind-var-lib-docker",
46+
"target": "/var/lib/docker",
47+
"type": "volume"
48+
},
49+
{
50+
"source": "./.volume",
51+
"target": "/data",
52+
"type": "bind",
53+
"consistency": "cached"
54+
}
55+
]
56+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Keep this folder for DevContainers DooD setup
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/devcontainers/base:bookworm
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "LocalStack DooD setup",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
6+
7+
// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
8+
"features": {
9+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
10+
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
11+
"version": "latest",
12+
"awslocal": true, // if true, add in features manually: ghcr.io/devcontainers/features/aws-cli
13+
"cdklocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/aws-cdk
14+
"pulumilocal": false, // if true, add in features manually: ghcr.io/devcontainers-contrib/features/pulumi
15+
"samlocal": false, // if true, add in features manually: ghcr.io/customink/codespaces-features/sam-cli
16+
"tflocal": false // if true, add in features manually: ghcr.io/devcontainers-contrib/features/terraform-asdf
17+
},
18+
"ghcr.io/devcontainers/features/aws-cli:1": {},
19+
"ghcr.io/devcontainers/features/python:1": {
20+
"version": "3.11"
21+
}
22+
}
23+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: "3.8"
2+
3+
services:
4+
localstack:
5+
container_name: "localstack-main"
6+
image: localstack/localstack-pro:latest # required for Pro
7+
ports:
8+
- "127.0.0.1:4566:4566" # LocalStack Gateway
9+
- "127.0.0.1:4510-4559:4510-4559" # external services port range
10+
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
11+
env_file:
12+
- .env
13+
volumes:
14+
- "/var/run/docker.sock:/var/run/docker.sock"
15+
- "./.volume:/var/lib/localstack"
16+
networks:
17+
ls:
18+
# Set the container IP address in the info subnet
19+
ipv4_address: 10.0.2.20
20+
21+
app:
22+
build:
23+
context: .
24+
dockerfile: Dockerfile
25+
volumes:
26+
- ../..:/workspaces:cached
27+
# Overrides default command so things don't shut down after the process ends.
28+
command: sleep infinity
29+
init: true
30+
env_file:
31+
- .env
32+
dns:
33+
# Set the DNS server to be the LocalStack container
34+
- 10.0.2.20
35+
networks:
36+
- ls
37+
38+
networks:
39+
ls:
40+
ipam:
41+
config:
42+
# Specify the subnet range for IP address allocation
43+
- subnet: 10.0.2.0/24
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
release-tag:
5+
type: string
6+
required: true
7+
description: This will be the version of the release, but will also be used as 'tag' for the localstack docker image
8+
push:
9+
paths-ignore:
10+
- ./*.md
11+
- LICENSE
12+
- .circleci/*
13+
- .gitlab-ci.yml
14+
branches:
15+
- main
16+
17+
permissions:
18+
contents: write
19+
20+
name: Create Release
21+
jobs:
22+
release:
23+
name: Create Release for Cloud Pod
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Set up Python 3.11
30+
id: setup-python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: 3.11
34+
35+
- name: Set up Project
36+
run: |
37+
pip install -r requirements-dev.txt
38+
39+
- name: Start LocalStack
40+
uses: LocalStack/[email protected]
41+
with:
42+
image-tag: ${{ inputs.release-tag || 'latest'}}
43+
use-pro: 'true'
44+
install-awslocal: 'true'
45+
env:
46+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
47+
48+
- name: Deploy infrastructure
49+
run: |
50+
bin/deploy.sh
51+
52+
- name: Run Tests
53+
env:
54+
AWS_DEFAULT_REGION: us-east-1
55+
AWS_REGION: us-east-1
56+
AWS_ACCESS_KEY_ID: test
57+
AWS_SECRET_ACCESS_KEY: test
58+
run: |
59+
pytest tests
60+
61+
# Not using action as state is not stored as an artifact
62+
- name: Save the Cloud Pod
63+
env:
64+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
65+
run: |
66+
localstack state export release-pod.zip
67+
68+
- name: Prepare Release Notes
69+
run: |
70+
echo "This release includes the Cloud Pod of the sample created with LocalStack Version \`${{ inputs.release-tag || 'latest'}}\`." > Release.txt
71+
echo "You can download the \`release-pod.zip\` and inject it manually by running \`localstack state import release-pod.zip\`, or use the Cloud Pods Launchpad." >> Release.txt
72+
echo "### Cloud Pods Launchpad" >> Release.txt
73+
echo "You can click the Launchpad to inject the the pod into your running LocalStack instance using the WebUI:" >> Release.txt
74+
echo "[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/$GITHUB_REPOSITORY/releases/download/${{ inputs.release-tag || 'latest'}}/release-pod.zip)" >> Release.txt
75+
76+
- name: Create Release
77+
id: create_release
78+
uses: softprops/action-gh-release@v1
79+
with:
80+
tag_name: "${{ inputs.release-tag || 'latest'}}"
81+
name: "Cloud Pod for LocalStack Version '${{ inputs.release-tag || 'latest'}}'"
82+
body_path: ./Release.txt
83+
files: |
84+
./release-pod.zip
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Run Integration Tests
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- ./*.md
7+
- LICENSE
8+
- .circleci/*
9+
- .gitlab-ci.yml
10+
branches:
11+
- main
12+
pull_request:
13+
branches:
14+
- main
15+
schedule:
16+
# “At 00:00 on Sunday.”
17+
- cron: "0 0 * * 0"
18+
workflow_dispatch:
19+
inputs:
20+
runner-os:
21+
default: ubuntu-latest
22+
type: choice
23+
options:
24+
- ubuntu-latest
25+
- macos-latest
26+
27+
28+
jobs:
29+
run-it-tests-job:
30+
runs-on: ${{ inputs.runner-os || 'ubuntu-latest' }}
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
35+
- name: Set up Python 3.11
36+
id: setup-python
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: 3.11
40+
41+
- name: Docker setup (macos only)
42+
id: setup-docker-mac
43+
if: ${{ runner.os == 'macOS' }}
44+
run: |
45+
brew install docker
46+
colima start
47+
48+
- name: Set up Project
49+
run: |
50+
pip install -r requirements-dev.txt
51+
52+
- name: Start LocalStack
53+
uses: LocalStack/[email protected]
54+
with:
55+
image-tag: 'latest'
56+
use-pro: 'true'
57+
configuration: LS_LOG=trace
58+
install-awslocal: 'true'
59+
env:
60+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
61+
62+
- name: Deploy infrastructure
63+
run: |
64+
bin/deploy.sh
65+
66+
- name: Run Tests
67+
env:
68+
AWS_DEFAULT_REGION: us-east-1
69+
AWS_REGION: us-east-1
70+
AWS_ACCESS_KEY_ID: test
71+
AWS_SECRET_ACCESS_KEY: test
72+
run: |
73+
pytest tests
74+
75+
- name: Show localstack logs
76+
if: always()
77+
run: |
78+
localstack logs
79+
80+
- name: Send a Slack notification
81+
if: failure() || github.event_name != 'pull_request'
82+
uses: ravsamhq/notify-slack-action@v2
83+
with:
84+
status: ${{ job.status }}
85+
token: ${{ secrets.GITHUB_TOKEN }}
86+
notification_title: "{workflow} has {status_message}"
87+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
88+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
89+
notify_when: "failure"
90+
env:
91+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
92+
93+
- name: Generate a Diagnostic Report
94+
if: failure()
95+
run: |
96+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
97+
98+
- name: Upload the Diagnostic Report
99+
if: failure()
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: diagnose.json.gz
103+
path: ./diagnose.json.gz
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Create PR Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths-ignore:
7+
- ./*.md
8+
- LICENSE
9+
- .circleci/*
10+
- .gitlab-ci.yml
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
permissions:
17+
pull-requests: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python 3.11
23+
id: setup-python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.11
27+
28+
- name: Install dependencies
29+
run: |
30+
pip install awscli-local
31+
32+
- name: Deploy Preview
33+
uses: LocalStack/[email protected]
34+
env:
35+
AWS_DEFAULT_REGION: us-east-1
36+
AWS_REGION: us-east-1
37+
AWS_ACCESS_KEY_ID: test
38+
AWS_SECRET_ACCESS_KEY: test
39+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
40+
with:
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
state-backend: ephemeral
43+
state-action: start
44+
skip-ephemeral-stop: 'true'
45+
include-preview: 'true'
46+
preview-cmd: |
47+
# Add your custom deployment commands here.
48+
# Below is an example for the Image resizer application.
49+
bin/deploy.sh

.github/workflows/sync.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Sync repo to Gitlab
2+
on: [ push, delete, workflow_dispatch ]
3+
4+
jobs:
5+
sync:
6+
name: Gitlab Sync
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- name: Mirroring Repository
14+
uses: pixta-dev/[email protected]
15+
with:
16+
target_repo_url: [email protected]:localstack.cloud/samples/sample-serverless-image-resizer-s3-lambda.git
17+
ssh_private_key: ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}

0 commit comments

Comments
 (0)