Skip to content

Commit b32b6af

Browse files
committed
chore: adjust dockerfile
1 parent e6c2c8b commit b32b6af

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ VITE_APP_VERSION=1.0.0
99

1010
# AWS Configuration for LocalStack
1111
VITE_AWS_DEFAULT_REGION=us-east-1
12+
VITE_AWS_ACCESS_KEY_ID=test
13+
VITE_AWS_SECRET_ACCESS_KEY=test
1214

1315
# Development settings
1416
VITE_DEV_MODE=true

Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ WORKDIR /app
77
COPY package*.json ./
88

99
# Install dependencies
10-
RUN npm ci --only=production
10+
RUN npm ci
1111

1212
# Copy source code
1313
COPY . .
1414

15+
# Add build arguments
16+
ARG VITE_LOCALSTACK_ENDPOINT
17+
ARG VITE_AWS_DEFAULT_REGION
18+
ARG VITE_AWS_ACCESS_KEY_ID
19+
ARG VITE_AWS_SECRET_ACCESS_KEY
20+
21+
# Set environment variables from build args
22+
ENV VITE_LOCALSTACK_ENDPOINT=${VITE_LOCALSTACK_ENDPOINT}
23+
ENV VITE_AWS_DEFAULT_REGION=${VITE_AWS_DEFAULT_REGION}
24+
ENV VITE_AWS_ACCESS_KEY_ID=${VITE_AWS_ACCESS_KEY_ID}
25+
ENV VITE_AWS_SECRET_ACCESS_KEY=${VITE_AWS_SECRET_ACCESS_KEY}
26+
1527
# Build the application
1628
RUN npm run build
1729

development-environment/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- SERVICES=sns,sqs,s3,lambda,dynamodb,kinesis,kms
1212
- DISABLE_CORS_CHECKS=1
1313
- DISABLE_CORS_HANDLERS=1
14-
- EXTRA_CORS_ALLOWED_ORIGINS=http://localhost:3000
14+
- EXTRA_CORS_ALLOWED_ORIGINS=*
1515
- EXTRA_CORS_ALLOWED_HEADERS=authorization,content-type,x-amz-date,x-amz-security-token,x-amz-user-agent,x-amz-invocation-type,x-amz-log-type
1616
volumes:
1717
- "${TMPDIR:-/tmp}/localstack:/var/lib/localstack"

src/stores/app.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { ref } from 'vue'
33
import AWS from 'aws-sdk'
44

55
export const useAppStore = defineStore('app', () => {
6-
const endpoint = ref(localStorage.getItem('localstack-endpoint') || 'http://localhost:4566')
6+
const endpoint = ref(import.meta.env.VITE_LOCALSTACK_ENDPOINT || 'http://localhost:4566')
7+
const region = ref(import.meta.env.VITE_AWS_DEFAULT_REGION || 'us-east-1')
8+
const accessKeyId = ref(import.meta.env.VITE_AWS_ACCESS_KEY_ID || 'test')
9+
const secretAccessKey = ref(import.meta.env.VITE_AWS_SECRET_ACCESS_KEY || 'test')
710
const connectionStatus = ref('disconnected')
811
const snackbar = ref({
912
show: false,
@@ -14,9 +17,9 @@ export const useAppStore = defineStore('app', () => {
1417

1518
// AWS SDK Configuration
1619
const awsConfig = {
17-
region: 'us-east-1',
18-
accessKeyId: 'test',
19-
secretAccessKey: 'test',
20+
region: region.value,
21+
accessKeyId: accessKeyId.value,
22+
secretAccessKey: secretAccessKey.value,
2023
endpoint: endpoint.value,
2124
s3ForcePathStyle: true,
2225
sslEnabled: false
@@ -53,12 +56,16 @@ export const useAppStore = defineStore('app', () => {
5356
const checkConnection = async () => {
5457
try {
5558
connectionStatus.value = 'connecting'
56-
59+
5760
// Try to list S3 buckets as a health check
5861
if (!s3.value) initializeServices()
59-
60-
await s3.value.listBuckets().promise()
61-
connectionStatus.value = 'connected'
62+
63+
if (s3.value) {
64+
await s3.value.listBuckets().promise()
65+
connectionStatus.value = 'connected'
66+
} else {
67+
connectionStatus.value = 'disconnected'
68+
}
6269
} catch (error) {
6370
connectionStatus.value = 'disconnected'
6471
console.error('Connection failed:', error)
@@ -74,7 +81,7 @@ export const useAppStore = defineStore('app', () => {
7481
}
7582
}
7683

77-
// Initialize services on store creation
84+
// Initialize services on store creation
7885
initializeServices()
7986

8087
return {

0 commit comments

Comments
 (0)