Skip to content

Commit e8816fa

Browse files
authored
Update Astro template (#196)
1 parent a4423b1 commit e8816fa

File tree

8 files changed

+46
-44
lines changed

8 files changed

+46
-44
lines changed

app/.astro-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0d4e135e169ed4bdedf1faee29e65eb0bf47914c
1+
df3f56679c68e14b702a775c4d4008501370168c

app/Dockerfile

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ FROM bitnami/nginx:1.29 AS nginx_upstream
1919
# --
2020
# Base image
2121

22-
FROM node_upstream AS app_base
22+
FROM node_upstream AS node_base
2323

2424
# Set app directory
2525
WORKDIR /app
@@ -29,32 +29,41 @@ ENV HOME=/tmp
2929

3030

3131
# --
32-
# Build base image
32+
# Build binary base image
3333

34-
FROM app_base AS app_build_base
34+
FROM node_base AS node_build_base
3535

3636
# Install pnpm
3737
RUN --mount=type=cache,target=~/.npm \
3838
npm install -g pnpm
3939

4040

4141
# --
42-
# Build dev image
42+
# Build base image
4343

44-
FROM app_build_base AS app_build_dev
44+
FROM node_build_base AS deps_base
4545

46-
# Copy app build configuration
46+
# Copy build configuration
4747
COPY --link ./app/package.json ./app/pnpm-lock.yaml ./
4848

49-
# Install app development dependencies
49+
50+
# --
51+
# Build dev image
52+
53+
FROM deps_base AS deps_dev
54+
55+
# Install development dependencies
5056
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
5157
pnpm install --frozen-lockfile
5258

59+
# Create Astro runtime directory
60+
RUN mkdir -p ./.astro
61+
5362

5463
# --
5564
# CLI image
5665

57-
FROM app_build_base AS app_cli
66+
FROM node_build_base AS app_cli
5867

5968
ARG UID
6069

@@ -90,7 +99,7 @@ CMD [ "--help" ]
9099
# --
91100
# Test base image
92101

93-
FROM app_build_base AS app_test_base
102+
FROM node_build_base AS test_base
94103

95104
# Build arguments
96105
ARG UID
@@ -100,13 +109,13 @@ ENV APP_ENV=test
100109
ENV NODE_ENV=development
101110

102111
# Copy app development dependencies
103-
COPY --link --from=app_build_dev --chown="${UID}:0" /app/node_modules ./node_modules
112+
COPY --link --from=deps_dev --chown="${UID}:0" /app/node_modules ./node_modules
104113

105114

106115
# --
107116
# Test unit image
108117

109-
FROM app_test_base AS app_test_unit
118+
FROM test_base AS test_unit
110119

111120
# Build arguments
112121
ARG UID
@@ -123,7 +132,7 @@ CMD [ "sh", "-c", "pnpm run test:vitest" ]
123132
# --
124133
# Test E2E image
125134

126-
FROM app_test_base AS app_test_e2e
135+
FROM test_base AS test_e2e
127136

128137
# Build arguments
129138
ARG UID
@@ -154,20 +163,20 @@ CMD [ "sh", "-c", "pnpm run test:playwright --output /tmp/playwright/test-result
154163
# --
155164
# Dev image
156165

157-
FROM app_build_base AS app_dev
166+
FROM node_build_base AS app_dev
158167

159168
ARG UID
160169

161170
# Set runtime environment
162171
ENV APP_ENV=dev
163-
ENV NODE_ENV=development
164172

165-
# Copy app development dependencies
166-
COPY --link --from=app_build_dev --chown="${UID}:0" /app/node_modules ./node_modules
173+
# Copy development dependencies
174+
ENV NODE_ENV=development
175+
COPY --link --from=deps_dev --chown="${UID}:0" /app/.astro ./.astro
176+
COPY --link --from=deps_dev --chown="${UID}:0" /app/node_modules ./node_modules
167177

168178
# Copy source code
169179
COPY --link --chown="${UID}:0" ./app .
170-
RUN mkdir -p ./.astro && chown -R "${UID}:0" ./.astro
171180

172181
# Create user 'user' in group 'root'
173182
RUN USERNAME="$(getent passwd "${UID}" | cut -d: -f1)"; \
@@ -186,22 +195,22 @@ ENV PORT=${PORT}
186195
EXPOSE ${PORT}
187196

188197
# Start development server
189-
CMD [ "sh", "-c", "pnpm run dev -- --host --port \"${PORT}\"" ]
198+
CMD [ "sh", "-c", "pnpm run dev --host --port \"${PORT}\"" ]
190199

191200

192201
# --
193202
# Prod build image
194203

195-
FROM app_build_base AS app_prod_build
204+
FROM node_build_base AS app_prod_build
196205

197206
ARG UID
198207

199208
# Set runtime environment
200209
ENV APP_ENV=prod
201-
ENV NODE_ENV=production
202210

203-
# Copy app development dependencies
204-
COPY --link --from=app_build_dev --chown="${UID}:0" /app/node_modules ./node_modules
211+
# Copy development dependencies
212+
ENV NODE_ENV=development
213+
COPY --link --from=deps_dev --chown="${UID}:0" /app/node_modules ./node_modules
205214

206215
# Copy source code
207216
COPY --link --chown="${UID}:0" ./app .

docker-compose-npm.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

docker-compose.cicd.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ services:
1414
- ./app/dist:/dist
1515

1616
app:
17+
# Extend
18+
extends:
19+
file: ./docker-compose.yml
20+
service: app
1721
# Build override
1822
image: ${IMAGES_PREFIX:-app}-cicd:${IMAGES_TAG:-latest}
1923
build:

docker-compose.override.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
services:
44

55
app:
6+
# Extend
7+
extends:
8+
file: ./docker-compose.yml
9+
service: app
610
# Build override
711
image: ${IMAGES_PREFIX:-app}-dev:${IMAGES_TAG:-latest}
812
build:

docker-compose.prod.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
services:
44

55
app:
6+
# Extend
7+
extends:
8+
file: ./docker-compose.yml
9+
service: app
610
# Deploy override
711
restart: unless-stopped

docker-compose.test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
# Build override
1111
image: ${IMAGES_PREFIX:-app}-test-e2e:${IMAGES_TAG:-latest}
1212
build:
13-
target: app_test_e2e
13+
target: test_e2e
1414
args:
1515
UID: ${DOCKER_UID:-${UID:-1000}}
1616
# Deploy override

docker-compose.test-unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
# Build override
1111
image: ${IMAGES_PREFIX:-app}-test-unit:${IMAGES_TAG:-latest}
1212
build:
13-
target: app_test_unit
13+
target: test_unit
1414
args:
1515
UID: ${DOCKER_UID:-${UID:-1000}}
1616
# Deploy override

0 commit comments

Comments
 (0)