Skip to content

Commit

Permalink
minor chnage in templates directory
Browse files Browse the repository at this point in the history
  • Loading branch information
suriya-mca committed Apr 22, 2024
1 parent 7f716e9 commit c803709
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 75 deletions.
22 changes: 20 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def podman_init(project_name, language):
type=click.Choice(['django', 'fastapi', 'flask', 'exit'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -31,6 +34,9 @@ def podman_init(project_name, language):
type=click.Choice(['spring', 'quarkus', 'micronaut', 'vertx', 'exit'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -42,6 +48,9 @@ def podman_init(project_name, language):
type=click.Choice(['gin', 'echo', 'chi', 'fiber', 'exit'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -53,6 +62,9 @@ def podman_init(project_name, language):
type=click.Choice(['express', 'nest', 'koa', 'fastify', 'exit'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -64,6 +76,9 @@ def podman_init(project_name, language):
type=click.Choice(['.net core', 'blazor'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -75,6 +90,9 @@ def podman_init(project_name, language):
type=click.Choice(['actix', 'axum', 'rocket', 'warp', 'tide', 'exit'], case_sensitive=False),
show_choices=True)

port = click.prompt('Choose port',
type=int)

if framework == 'exit':
click.echo(style("Exiting...", fg='red'))
sys.exit()
Expand All @@ -88,13 +106,13 @@ def podman_init(project_name, language):
load_jinja_env = Environment(loader=FileSystemLoader(template_dir))

dockerfile_template = load_jinja_env.get_template('Dockerfile.j2')
dockerfile_content = dockerfile_template.render(project_name=project_name, framework=framework)
dockerfile_content = dockerfile_template.render(project_name=project_name, framework=framework, port=port)

with open('Dockerfile', 'w') as f:
f.write(dockerfile_content)

compose_template = load_jinja_env.get_template('docker-compose.yml.j2')
compose_content = compose_template.render(project_name=project_name, framework=framework)
compose_content = compose_template.render(project_name=project_name, framework=framework, port=port)

with open('docker-compose.yml', 'w') as f:
f.write(compose_content)
Expand Down
2 changes: 1 addition & 1 deletion src/templates/c#/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
{% if framework == 'dot-net_core' %}container_name: dot-net_core
{% elif framework == 'blazor' %}container_name: blazor
{% endif %}ports:
- "5000:80"
- "{{ port }}:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development

Expand Down
6 changes: 2 additions & 4 deletions src/templates/go/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ FROM alpine:latest
COPY --from=build /app/main .

# Expose port 3000 to the outside world
{% if framework == 'gin' or framework == 'echo' %}EXPOSE 8080
{% elif framework == 'chi' %}EXPOSE 3333
{% elif framework == 'fiber' %}EXPOSE 3000
{% endif %}
EXPOSE {{ port }}

# Command to run the executable
CMD ["./main"]
11 changes: 2 additions & 9 deletions src/templates/go/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ services:
context: .
dockerfile: Dockerfile
{% if framework == 'gin' %}container_name: gin
ports:
- "8080:8080"
{% elif framework == 'echo' %}container_name: echo
ports:
- "8080:8080"
{% elif framework == 'chi' %}container_name: chi
ports:
- "3333:3333"
{% elif framework == 'fiber' %}container_name: fiber
ports:
- "3000:3000"
{% endif %}
{% endif %}ports:
- "{{ port }}:{{ port }}"
# Add additional configurations as needed
2 changes: 1 addition & 1 deletion src/templates/java/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /src
COPY target/*.jar /src/app.jar

# Expose port 8080 to allow external access to the application
EXPOSE 8080
EXPOSE {{ port }}

# Define the entry point to execute the application when the container starts
ENTRYPOINT ["java", "-jar" , "app.jar"]
2 changes: 1 addition & 1 deletion src/templates/java/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ services:
{% elif framework == 'micronaut' %}container_name: micronaut
{% elif framework == 'vertx' %}container_name: vertx
{% endif %}ports:
- "8080:8080"
- "{{ port }}:{{ port }}"

# Add additional configurations as needed
4 changes: 2 additions & 2 deletions src/templates/node/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ RUN npm install
# Copy the rest of the application code to the working directory
COPY . .

# Expose port 3000
EXPOSE 3000
# Expose port
EXPOSE {{ port }}

# Command to run the application
CMD ["node", "app.js"]
2 changes: 1 addition & 1 deletion src/templates/node/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
{% elif framework == 'koa' %}container_name: koa
{% elif framework == 'fastify' %}container_name: fastify
{% endif %}ports:
- "3000:3000"
- "{{ port }}:{{ port }}"
volumes:
- .:/usr/src/app
environment:
Expand Down
12 changes: 5 additions & 7 deletions src/templates/python/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ RUN pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt && \

# Expose ports and define startup commands based on selected framework
{% if framework == 'django' %}EXPOSE 8000

EXPOSE {{ port }}
{% if framework == 'django' %}
# Specify the entry point
CMD ["python", "manage.py", "runserver"]

{% elif framework == 'fastapi' %}EXPOSE 8000

# # Specify the entry point (Replace "mail" with your actual file name)
{% elif framework == 'fastapi' %}
# Specify the entry point (Replace "mail" with your actual file name)
CMD ["uvicorn", "main:app", "--host=0.0.0.0", "--reload"]

{% elif framework == 'flask' %}EXPOSE 5000

{% elif framework == 'flask' %}
# Specify the entry point
CMD ["flask", "run"]
{% endif %}
12 changes: 4 additions & 8 deletions src/templates/python/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ services:
context: .
dockerfile: Dockerfile
{% if framework == 'django' %}container_name: django
ports:
- "8000:8000"
{% elif framework == 'fastapi' %}container_name: fastapi
ports:
- "8000:8000"
{% elif framework == 'flask' %}container_name: flask
ports:
- "5000:5000"
{% endif %}volumes:
{% elif framework == 'flask' %}container_name: flask
{% endif %}ports:
- "{{ port }}:{{ port }}"
volumes:
- .:/app

# Add additional configurations as needed
7 changes: 2 additions & 5 deletions src/templates/rust/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ FROM debian:buster-slim
COPY --from=builder /usr/src/myapp/target/release/myapp .

# Expose the port the Actix Web application will listen on
{% if framework == 'actix' %}EXPOSE 8080
{% elif framework == 'axum' %}EXPOSE 3000
{% elif framework == 'rocket' or framework == 'tide' %}EXPOSE 8000
{% elif framework == 'warp' %}EXPOSE 3030
{% endif %}
Expose {{ port }}

# Command to run the application
CMD ["./myapp"]
15 changes: 3 additions & 12 deletions src/templates/rust/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@ services:
context: .
dockerfile: Dockerfile
{% if framework == 'actix' %}container_name: actix
ports:
- "8080:8080"
{% elif framework == 'axum' %}container_name: axum
ports:
- "3000:3000"
{% elif framework == 'rocket' %}container_name: rocket
ports:
- "8000:8000"
{% elif framework == 'warp' %}container_name: warp
ports:
- "3030:3030"
{% elif framework == 'tide' %}container_name: tide
ports:
- "8000:8000"
{% endif %}
{% elif framework == 'tide' %}container_name: tide
{% endif %}ports:
- "{{ port }}:{{ port }}"
# Add additional configurations as needed
Loading

0 comments on commit c803709

Please sign in to comment.