Hello. I am trying to deploy a custom container to...
# general
q
Hello. I am trying to deploy a custom container to fargate and want to automate this using pulumi. https://www.pulumi.com/blog/get-started-with-docker-on-aws-fargate-using-pulumi/ I am referring this article but my custom image comprises of 2 images (frontend and backend) and they are built using docker-compose. Is there a way to point to the docker-compose file in the new ecs image instantiation code in pulumi ?
Copy code
const img = awsx.ecs.Image.fromPath("app-img", "./app");
Ideally, i need this to build the image from docker-compose rather than taking the dockerfile.
FYI, For my purpose, i don't necessarily need to deploy the backend separately. (Don't need to scale them out that way)
If this is already addressed before please point me to the slack thread and i can figure out on my own.
m
Is there a way to point to the docker-compose file in the new ecs image instantiation code in pulumi?
There is not; that reference is to a folder containing a Dockerfile — and I don’t think there’s any direct integration with docker-compose (though someone should correct me if that’s no longer correct).
If you could share/point to a bit of code & context, though, we might be able to help you along somehow
q
Sorry for the delayed reply @miniature-musician-31262
Copy code
version: "3.7"

services:
  frontend:
    build: frontend
    ports:
      - 8501:8501
    networks: 
      companynetwork: 
        aliases: 
          - frontend.docker
    depends_on:
      - backend
    volumes:
        - ./frontend:/app
        - ./data:/data
        - ./src:/app/src
        - ./env:/app/env

  backend:
    build: backend
    ports:
      - 1000:1000
    networks: 
      agpnetwork: 
        aliases: 
          - backend.docker
    volumes:
      - ./backend:/app
      - ./data:/data
      - ./src:/app/src
      - ./env:/app/env


networks:
  companynetwork:
    external: false
This is the docker-compose file i have. The frontend is a streamlit server and the backend is a fast api server running on two different ports. I feel like having them together makes it slightly easier to connect the frontend and backend together . I don't want to deploy it separately as this is an internal tool and i won't expect the need to scale
m
Ok thanks. Yeah, I think in order to run these containers as Fargate tasks, you’ll need to “decompose” this docker-compose file and turn it into a Pulumi program. I’ll see if I can find a good example for you.
q
Hi @miniature-musician-31262. Any alternatives other than to "decompose" my docker file ? Just so i understand, say if a functionality exists within pulumi to integrate a docker compose file would that be considered anti pattern ?
m
Hi @quaint-garden-29833. Yeah, I’ve looked around again, and unfortunately I don’t see any way to directly translate a docker-compose file into a set of deployed services in AWS like this. Ultimately you’re going to need to convert those services into ECS tasks.
We have lots of examples in
pulumi/examples
that demonstrate using our
@pulumi/aws
and
@pulumi/awsx
libraries to do this, so I’d encourage you to take a look: https://github.com/pulumi/examples