54
loading...
This website collects cookies to deliver better user experience
$ aws --version
aws-cli/2.2.35 Python/3.8.0 Darwin/20.5.0 source/x86_64 prompt/off
$ copilot --version
Copilot version: v1.13.0
$ docker --version
Docker version 20.10.11, build dea9396
$ mkdir copilot-express && cd copilot-express
$ npm init -y
$ npm install -D typescript ts-node @types/node @types/node @types/express
$ npm install express
$ npx tsc --init
$ touch index.ts
index.ts
, we will start Express and define a GET request handler for /
.import express from 'express';
import { Request, Response } from 'express';
const app = express();
const port = 3000;
app.get('/', (req: Request, res: Response) => res.send('Express app works!'));
app.listen(port, () => console.info(`Express listening on port ${port}!`));
"start": "ts-node index.ts"
to scripts in package.json.{
"scripts": {
"start": "ts-node index.ts"
}
}
$ touch Dockerfile
FROM node:16
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
$ docker build -t copilot-express .
$ docker images | grep copilot-express
$ docker run -p 3000:3000 -d copilot-express
Express app works!
you're ready to go.copilot init
to initialize & deploy.$ copilot init
Note: It's best to run this command in the root of your Git repository.
Welcome to the Copilot CLI! We're going to walk you through some questions
To help you get set up with a containerized application on AWS. An application is a collection of
An application is a collection of containerized services that operate together.
What would you like to name your application? for help] copilot-express
Which workload type best represents your architecture? for more help].
Request-Driven Web Service (App Runner)
> Load Balanced Web Service (Internet to ECS on Fargate)
Backend Service (ECS on Fargate)
Worker Service (Events to SQS to ECS on Fargate)
Scheduled Job (Scheduled event to State Machine to Fargate)
What do you want to name this service? for help] api
Which Dockerfile would you like to use for api? [Use arrows to move, type to filter, ? for more help]
> ./Dockerfile
Enter custom path for your Dockerfile
Use an existing image instead
All right, you're all set for local development.
Would you like to deploy a test environment? for help] (y/N) y
✔ Linked account AWS_ACCOUNT_ID and region ap-northeast-1 to application copilot-express..
✔ Proposing infrastructure changes for the copilot-express-test environment.
✔ Created environment test in region ap-northeast-1 under application copilot-express.
✔ Deployed service api.
Recommended follow-up action:
- You can access your service at http://xxxxx.ap-northeast-1.elb.amazonaws.com over the internet.
Express app works!
as you did locally, deployment is complete!$ copilot app delete