Skip to content

Commit d237cb0

Browse files
Merge pull request #181 from DefangLabs/174-platformatic-sample
174 platformatic sample
2 parents cb1b0b7 + 7bc7c9f commit d237cb0

File tree

26 files changed

+8097
-0
lines changed

26 files changed

+8097
-0
lines changed

.github/workflows/check-sample.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
./scripts/check-modified-samples.sh > modified.txt
3131
echo "@@ MODIFIED @@"
3232
cat modified.txt
33+
echo "@@ CHECKLIST @@"
34+
cat checklist.txt
3335
3436
# TODO: Uncomment the following lines to validate the Compose files
3537
# once we figure out how to prevent it from erroring on warnings.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Note: universal image is not compatible with the devcontainer tools.
2+
# we use the typescript-node image instead here but should switch out per
3+
# project requirements. #REMOVE_ME_AFTER_EDITING
4+
5+
# FROM mcr.microsoft.com/devcontainers/go:1.22-bookworm
6+
# FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm
7+
# FROM mcr.microsoft.com/devcontainers/php:8.3-bookworm
8+
# FROM mcr.microsoft.com/devcontainers/ruby:3.2-bookworm
9+
# FROM mcr.microsoft.com/devcontainers/java:11-bookworm
10+
# FROM mcr.microsoft.com/devcontainers/rust:1-bookworm
11+
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
}
10+
}

samples/platformatic/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- name: Deploy
20+
uses: DefangLabs/[email protected]
21+
#REMOVE_ME_AFTER_EDITING - Replace the following line with the list of environment variables you want to pass to the action
22+
with:
23+
config-env-vars: ENV1 ENV2
24+
env:
25+
ENV1: ${{ secrets.ENV1 }}
26+
ENV2: ${{ secrets.ENV2 }}

samples/platformatic/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

samples/platformatic/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Platformatic App
2+
3+
This sample project demonstrates how to deploy a simplist Platformatic service that returns "Platformatic x Defang" when accessed. The project includes a Dockerized setup with Docker Compose, making it easy to deploy and manage the service.
4+
5+
Once your app is up and running, you can access it via the defined port (default is 3042). This service is designed to be simple, showcasing how to set up a basic Platformatic application and deploy it using Docker.
6+
7+
## Prerequisites
8+
9+
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a>
10+
2. (optional) If you are using <a href="https://docs.defang.io/docs/concepts/defang-byoc">Defang BYOC</a>, make sure you have properly <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">authenticated your AWS account</a>.
11+
12+
## Deploying
13+
14+
1. Open the terminal and type `defang login`
15+
2. Navigate to the directory "app" with `cd ./app`
16+
3. Type `defang compose up` in the CLI.
17+
4. Your app will be running within a few minutes.
18+
19+
## Local Development
20+
21+
1. After cloning the repository and navigating to the root directory of the project, navigate to the directory called "app" with `cd app`
22+
2. Run `docker compose -f compose.dev.yaml up --build`
23+
24+
---
25+
26+
Title: Platformatic
27+
28+
Short Description: A sample project showcasing a simple Platformatic service with Docker deployment.
29+
30+
Tags: Platformatic, Defang, Docker, Node.js, Service, JavaScript
31+
32+
Languages: nodejs
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PLT_SERVER_HOSTNAME=127.0.0.1
2+
PORT=3042
3+
PLT_SERVER_LOGGER_LEVEL=info
4+
PLT_MANAGEMENT_API=true
5+
PLT_SERVICE1_TYPESCRIPT=false
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
dist
2+
.DS_Store
3+
4+
# dotenv environment variable files
5+
.env
6+
7+
# database files
8+
*.sqlite
9+
*.sqlite3
10+
11+
# Logs
12+
logs
13+
*.log
14+
npm-debug.log*
15+
yarn-debug.log*
16+
yarn-error.log*
17+
lerna-debug.log*
18+
.pnpm-debug.log*
19+
20+
# Dependency directories
21+
node_modules/
22+
23+
# ctags
24+
tags
25+
26+
# clinicjs
27+
.clinic/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use the official Node.js image as the base image
2+
FROM node:20-bookworm-slim
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install the dependencies
11+
RUN npm install --production
12+
13+
# Copy the rest of the application code to the working directory
14+
COPY . .
15+
16+
# Expose the application port
17+
EXPOSE 3042
18+
19+
# Define the command to run your application
20+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)