Skip to content

Commit c258e93

Browse files
authored
Merge pull request #1750 from rust-lang/pa-deploy
Add workflow to deploy changes to ECS
2 parents 7c6715a + 7a5b98b commit c258e93

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
3+
name: Deploy
4+
on:
5+
workflow_dispatch: {}
6+
7+
jobs:
8+
prod:
9+
name: Production
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Build the Docker image
15+
run: docker build -t docs-rs-web -f dockerfiles/Dockerfile --target web-server .
16+
17+
- name: Upload the Docker image to ECR
18+
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master
19+
with:
20+
image: docs-rs-web
21+
repository: docs-rs-web
22+
region: us-west-1
23+
aws_access_key_id: "${{ secrets.aws_access_key_id }}"
24+
aws_secret_access_key: "${{ secrets.aws_secret_access_key }}"
25+
redeploy_ecs_cluster: rust-ecs-prod
26+
redeploy_ecs_service: docs-rs-web

dockerfiles/Dockerfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Build stage #
1010
#################
1111

12-
FROM ubuntu:bionic AS build
12+
FROM ubuntu:22.04 AS build
1313

1414
# Install packaged dependencies
1515
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -53,11 +53,33 @@ COPY vendor vendor/
5353

5454
RUN cargo build --release
5555

56+
######################
57+
# Web server stage #
58+
######################
59+
60+
FROM ubuntu:22.04 AS web-server
61+
62+
RUN apt-get update \
63+
&& DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
64+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
65+
ca-certificates \
66+
tini \
67+
&& rm -rf /var/lib/apt/lists/*
68+
69+
COPY --from=build /build/target/release/cratesfyi /usr/local/bin
70+
COPY static /srv/docsrs/static
71+
COPY templates /srv/docsrs/templates
72+
COPY vendor /srv/docsrs/vendor
73+
74+
WORKDIR /srv/docsrs
75+
# Tini is a small init binary to properly handle signals
76+
CMD ["/usr/bin/tini", "/usr/local/bin/cratesfyi", "start-web-server", "0.0.0.0:80"]
77+
5678
##################
5779
# Output stage #
5880
##################
5981

60-
FROM ubuntu:bionic AS output
82+
FROM ubuntu:22.04 AS output
6183

6284
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
6385
git \

0 commit comments

Comments
 (0)